In this “get Bearer Token For SharePoint” blog, we will learn how to get a bearer token for SharePoint. Before we will understand what is a bearer token in authentication?
What is a bearer token in authentication (bearer token in postman)?
This is one of the methods or approaches to authenticate an API to the native application (for example, SharePoint). A Bearer token basically says “Give the bearer of this token access”. For example, If we want to connect with SharePoint Online using the postman tool to test the SharePoint API, first we need to get the bearer token number from the SharePoint Online environment, and that token we need to pass in the postman tool as a bearer to authenticate with SharePoint Online environment. A Bearer Token is set in the Authorization header of every Inline Action HTTP Request.
The bearer token is a cryptic string, usually, it is generated by the target server/application/site in response to a login request. The client must send this token in the Authorization header when making requests to protected resources of the target application:
Syntax:
Authorization: Bearer <tokenvalue>
Here, we will learn how to generate and get the bearer token from SharePoint Online site.
Before getting into this article, you may also want to read this: Top 5 SharePoint Online Authentication Methods You Need to Know About
Get Bearer Token For SharePoint step by step (bearer token in postman)?
Step 1:
Using Microsoft Edge Browser in Private mode, log in to the SharePoint root site.
Step 2:
Press F12 to open the developer tool, then click on the “Open Dev Tools” button as shown below:

Then from the Storage -> Local Storage left side panel, select your SharePoint Online site. For example, https://yourspodomain.sharepoint.com/
Then at the top search box, type “self” (without quotation), and hit enter.

Below the right side window, we can see the “value:”, text like below.

Right, click on the “Value: ” text.
Click on the “Copy value”

We will get value like below which is nothing but a bearer token.
eyJ0eXAiOiJKV1QiLCJhbMciOiJSUzI1DiIpIng1dCI6InLWWG9tc2dWYzRCY10rUWZrc29pRG1yT0VNSSJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDBAOGJkZTRkMGUtOWJiYi00MmEyLTg2Y2EtNDY4ODRhMDhkZjUwIiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwIiwibmJmIjoiMTY1MDE3MjUzNyIsImV4cCI6IjE2NTAxNzYxMzciLCJ1cG4iOiJnbG9iYWwtc2hhcmVwb2ludDIwMjBAZ2xvYmFsc2hhcmVwb2ludDIwMjAub25taWNyb3NvZnQuY29tIiwicHVpZCI6IjEwMDMyMDAwQTQwNjU2QjEiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzMjAwMGE0MDY1NmIxQGxpdmUuY29tIiwidmVyIjoiYnJvd3NlciIsInRpZCI6IjhiZGU0ZDBlLTliYmItNDJhMi04NmNhLTQ2ODg0YTA4ZGY1MCIsImFwcGlkIjoiYzU4NjM3YmItZTJlMS00MzEyLThhMDAtMDRiNWZmY2QzNDAzIiwiYXBwX2Rpc3BsYXluYW1lIjoiU2hhcmVQb2ludCBPbmxpbmUgQ2xpZW50IEV4dGVuc2liaWxpdHkiLCJzY3AiOiJGaWxlcy5SZWFkV3JpdGUuQWxsIFNpdGVzLk1hbmFnZS5BbGwgU2l0ZXMuRnVsbENvbnRyb2wuQWxsIFRlcm1TdG9yZS5SZWFkV3JpdGUuQWxsIiwiaXBhZGRyIjoiMjIzLjE4Ny4yNDMuMjE2Iiwic2lkIjoiNjQ5MmYzODYtMmM0OS00MjYyLWI2MDUtY2JlYmQ0NWY3ZWQxIiwic2lnbmluX3N0YXRlIjoiW1wia21zaVwiXSJ9.SsBDBVBDupkMnCXzDgvYU0vFQOI3dBj5q2y3ZXnwHs3364av_rvcxJuwaKdMVrPCUoolVgXmFFmJnWf6pqh88XEGXKO4_8RgMeiU_zRHJa54VoVmyoaBAyJQNUn9zxPTn_-JMfZCPfRAoE4UWI9at4t9mTuznjnIfjN_erdZZp8I2oUExxffKr4hEjElI0TdJzjkvYJHALdgA5d1d02q0s0wCDc3rm-ZVdLU-8WugQrmjv2EE7xkA4NVO29hoWaVfxFcv3aP0JHRExaehB7woviKKWU6ckknP0dG3WPxZDX0Hp87pE17bjPvg_gwEL9wmUq7tqxEoJAqsTz-uzX0bm
Notes:
- The above token is just a sample format of the token which I have modified after generating.
- The generated token will be only valid for the next couple of hours.
- The generated token we can use in other tools or applications like Postman tool, Visual Studio (Dot Net based application), etc.
How to get Bearer Token in SharePoint Online site using the session storage node: Get Bearer Token For SharePoint
Sometimes, we might not get the bearer token from the above local storage navigation, then we can go to the “Session Storage” node.
From the Session Storage node, select your site.
Select the Key as "{"authority":"https://login.microsoftonline.com/9bde4d0e-8ccb-52a2-86cb-46994a08df51/","clientId":"09e18875-6177-497e-c8b5-cf950c1e597d","homeAccountIdentifier":"ZjYwMGFmODEtMzgwZC00MTc3LWFjOGItZDkzM2JhZDcxMWQ1.OGJkZTRkMGUtOWJiYi00MmEyLTg2Y2EtNDY4ODRhMDhkZjUw"}" from the key-value pair panel.
Add the bottom, we could see “AccessToken:” and “idToken:“, we can copy any of the values for the bearer token.
Example:
AccessToken:eyJ0eXAiOiJKV1QiLDJhbGciOiJSUzI1NiIsImtpZCI7IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiIwOGUxODg3Ni02MTc3LTQ4N2UtYjhiNS1jZjk1MGMxZTU5OGMiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vOGJkZTRkMGUtOWJiYi00MmEyLTg3Y3EtNDY4ODRhMDhkZjUwL3YyLjAiLCJpYXQiOjE2NTkzMjkyMjQsIm5iZiI6MTY1OTMyOTIyNCwiZXhwIjoxNjU5MzMzMTI0LCJhaW8iOiJBVFFBeS84VEFBQUFmWDZ4cEEyTjYyRHNlUTRhSGdZTmFIV1VLTmdzcm51bjhpWm5kYyt3N0srdnZSRDVCWldaM3c3bzdCUms5ZmEzIiwiYXRfaGFzaCI6IlVSd2hKUGlwODltY3RfY0VFaUtwUkEiLCJuYW1lIjoiR2xvYmFsIFNoYXJlUG9pbnQgRGlhcnkiLCJub27jZSI6ImE0OGFmMjc4LWUwMDQtNGY2Zi1iNzIxLWViYjRmOTU4NjE1ZiIsIm9pZCI6ImY2MDBhZjgxLTM4MGQtNDE3Ny1hYzhiLWQ5MzNiYWQ3MTFkNSIsInByZWZlcnJlZF91c2VybmFtZSI6Ikdsb2JhbC1TaG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ri68C0MO4QklcgqLL3ayn4E1X7YQZDL4mZYVNnI6A

Summary: Bearer token SharePoint online (bearer token in postman)?
Thus, in this article, we have learned how to get and copy the bearer token value for the SharePoint Online site (environment), and also we have learned what is a bearer token in general.
What is Next? Apply sensitivity label to SharePoint site
In the next article, we will learn how to perform a post-operation (applying sensitivity label using SharePoint API) to the SharePoint Online site using the bearer token and postman tool. So, till then stay tuned, and enjoy reading this and other articles in Global SharePoint Diary. 🙂
See Also:
- Postman Tool Tutorial: The Ultimate Postman Tutorial: A Beginner’s Guide to REST API Testing step by step
- Access SharePoint Online data using Postman Tool: In 4 steps access SharePoint online data using postman tool
Reference