How to Pass a Bearer Token When Embedding PowerPoint in an Iframe
Question details
The user needs to pass a bearer token in the authorization header to securely embed a PowerPoint file using an iframe and the Office web viewer.

- Product
- PowerPoint / Office Web Viewer
- Device & OS
- not provided
- Scenario
- Embedding a secure PowerPoint file in a web application using an iframe where authentication is required.
- Observed behavior
- Standard HTML iframes do not support adding custom Authorization headers directly, preventing the embedded presentation from loading due to missing bearer tokens.
Verify that your bearer token is valid, has not expired, and that you have backend access to your web application to implement server-side routing.
Use a Server-Side Proxy to Inject the Bearer Token
Since HTML iframes cannot append custom headers natively, routing the request through a server-side proxy is the most reliable way to handle authorization securely.
Standard HTML <iframe> tags do not allow developers to set custom HTTP headers, including the Authorization header required by secure endpoints. To bypass this limitation, you can route the iframe source URL through a secure endpoint on your own backend server.
Your server will handle the authentication by attaching the bearer token to the request, fetching the document securely, and then streaming it back to the client-side iframe.
Set up a new API endpoint on your web server (e.g., /api/fetch-presentation) to handle the incoming iframe request.
In your server's route handler, make an HTTP request to the actual Office web viewer or secure PowerPoint file URL. Append the header 'Authorization: Bearer YOUR_TOKEN' to this backend request.
Take the response from the secure endpoint and stream the document data directly back to the client as the response from your backend route.
In your frontend HTML, change your iframe's src attribute to point to your new backend route instead of the direct file URL (e.g., <iframe src="/api/fetch-presentation"></iframe>).

Fetch the File via JavaScript and Create an Object URL
Use the JavaScript Fetch API to securely request the file with headers, convert it to a Blob, and embed it using an Object URL.
Try WPS Office for Seamless Presentation Management
Dealing with complex embedding permissions, web viewer restrictions, and authorization headers can be frustrating for document sharing. Consider switching to WPS Office, a highly compatible, free, and lightweight suite that simplifies creating, sharing, and viewing presentations without the hassle of complex web setups.
- 1. Download the application: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install WPS Office: Run the downloaded setup file and follow the simple on-screen instructions to complete the installation.
- 3. Manage your presentations: Launch WPS Presentation to instantly open, edit, and easily share your existing PowerPoint files securely.

Frequently Asked Questions
Can I pass an authorization header directly in an HTML iframe tag?
No, the standard HTML specification does not allow developers to add custom HTTP headers, such as an Authorization header containing a bearer token, directly to an iframe's src attribute. A server-side proxy or JavaScript Fetch approach is required.
Is it safe to pass the bearer token as a URL query parameter instead?
Passing authentication tokens in the URL (e.g., ?access_token=YOUR_TOKEN) is highly discouraged due to security risks. URLs are often logged in browser histories, proxy server logs, and HTTP referer headers, which can expose your token to unauthorized users.
Why does the Office web viewer require a bearer token?
The bearer token is used to authenticate the user and authorize access to securely stored files. It ensures that only users or applications with the correct permissions can load, view, and interact with the embedded PowerPoint presentation.
Will the Object URL approach work for all Office web viewer embeds?
Not necessarily. The Object URL approach requires downloading the actual file blob locally to the browser. If the Office web viewer relies on rendering the document via Microsoft's remote servers using a live URL, the file must be publicly accessible or accessed via a server-side proxy.




