microsoftgraph / msgraph-sample-reactspa

This sample demonstrates how to use the Microsoft Graph JavaScript SDK to access data in Office 365 from React browser apps.
MIT License
125 stars 105 forks source link

Error: Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant. #74

Closed yingying96 closed 3 years ago

yingying96 commented 3 years ago

Current Config:

  1. Supported account types: Who can use this application or access this API?
    • Selection: Accounts in this organizational directory only (Single tenant)
  2. Changed app ID, set redirect URL to localhost:3000

Error: Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.

Is it possible to use single tenant and resolve this error? Thanks!

jasonjoh commented 3 years ago

Yes. You will need to change the default authority for the MSAL library to your tenant-specific authority. By default, MSAL uses https://login.microsoftonline.com/common to do authentication, but that only works for multi-tenant apps. In this code:

https://github.com/microsoftgraph/msgraph-training-reactspa/blob/b20484072e9e56bdcbc318df6fb1b074ead98eba/demo/graph-tutorial/src/AuthProvider.tsx#L40-L43

Add a property authority inside the auth object, and set it to https://login.microsoftonline.com/YOUR_TENANT_ID, where YOUR_TENANT_ID is your tenant ID.

See https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md for details.

yingying96 commented 3 years ago

Yes that works. Thanks!