I am creating a webpart for SharePoint Online which accesse the user's calendar through the Microsoft Graph API.

In order to get the access_token, my webpart needs to open a new browser window where the user logs in with their Microsoft account. I am using OAuth v2.

However, my customer says this is not necessary because the user is already logged into SharePoint online, therefore there is no need to log in again an there must be a way to get the access token without having to log in again.

Is there a way to get the access_token for the Microsoft Graph API from inside a SharePoint online page without prompting the user and without opening that Microsoft account login window?

  • Have you found any work around for this problem?
    – Farhan
    Commented Mar 11, 2019 at 12:56

1 Answer 1


In order to obtain an access token, the user must authenticate themselves using their Microsoft account or organizational account, and they must grant consent for the requested permissions. This is typically done using the OAuth 2.0 authorization code flow or the implicit grant flow, which involve opening a login window and prompting the user to enter their credentials and grant consent.

However, once the user has authenticated and granted consent, the access token can be stored securely in the browser session or in a cookie, and can be used to make subsequent calls to the Graph API without prompting the user again. This can help to improve the user experience by avoiding unnecessary login prompts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.