alexandrtovmach / react-microsoft-login

Microsoft services authorization with React.
https://alexandrtovmach.github.io/react-microsoft-login
MIT License
80 stars 38 forks source link

Getting CORS error #47

Closed reachtokish closed 4 years ago

reachtokish commented 4 years ago

I'm getting the below CORS error while trying to implement this library

image

Below is my component

<MicrosoftLogin
  clientId={CLIENT_ID}
  authCallback={authHandler}
  debug={true}
  tenantUrl="https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize"
/>

Can anyone kindly tell me what could be the possible reason for this error?

alexandrtovmach commented 4 years ago

Thanks for report 👍 Seems like you're using tenantUrl, so probably you haven't allowed localhost in your organization

reachtokish commented 4 years ago

Thanks @alexandrtovmach for the info. I will check my azure configuration.

reachtokish commented 4 years ago

This issue is resolved. So my azure application is not multi-tenant and that is why I can't use /common in the url. And in that case I have to pass an extra parameter which is tenantUrl. And tenantUrl also I was passing wrong. Below is the example code which worked for me if that helps anyone.

<MicrosoftLogin
  clientId="YOUR_CLIENT_ID"
  authCallback={(error, authData) => authHandler(error, authData)}
  tenantUrl="https://login.microsoftonline.com/YOUR_TENANT_ID"
/>

Thanks for the great library!

alexandrtovmach commented 4 years ago

@reachtokish Thank you :+1: