alexandrtovmach / react-microsoft-login

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

Unable to get response or data in authHandler #61

Closed iamAbdulAhad3481 closed 3 years ago

iamAbdulAhad3481 commented 4 years ago

Hey i am using this react-microsoft-login for simple microsoft authentication. I had created and registered application and follows all steps and i successfully redirect to redirect uri now i am facing an issue that i am not getting any data in auth handler all i getting is undeifned when i console data. Here is my code

`import React, { FC } from 'react';
import MicrosoftLogin from "react-microsoft-login";

const Login: FC<any> = () => {

  const authHandler = (err: any, data: any) => {
    console.log(data);
  };
  return (
    <div>
       <MicrosoftLogin 
        clientId={'2605a4bf-3a94-4e4f-ab05-7d620c85c248'} 
        redirectUri={'http://localhost:3000/login'}
        graphScopes={["user.read"]}
        authCallback={authHandler}
        withUserData={true}
        />
    </div>
  )
}

export default Login;`

Please can anyone help me out in what is problem in here and suggest the correct way of implementing the auth flow. Thanks in advance.

iamAbdulAhad3481 commented 4 years ago

@alexandrtovmach Can you please have a look.

iamAbdulAhad3481 commented 4 years ago

@alexandrtovmach 1 thing more to mention when i console error i get this

ServerError: The request is not valid for the application's 'userAudience' configuration. In order to use /common/ endpoint, the application must not be configured with 'Consumer' as the user audience. The userAudience should be configured with 'All' to use /common/ endpoint. at ServerError.AuthError [as constructor] (http://localhost:3000/static/js/1.chunk.js:24943:24) at new ServerError (http://localhost:3000/static/js/1.chunk.js:25526:24) at UserAgentApplication.saveTokenFromHash (http://localhost:3000/static/js/1.chunk.js:23060:17) at UserAgentApplication.processCallBack (http://localhost:3000/static/js/1.chunk.js:22488:23) at UserAgentApplication.handleAuthenticationResponse (http://localhost:3000/static/js/1.chunk.js:22549:10) at UserAgentApplication. (http://localhost:3000/static/js/1.chunk.js:21797:18) at step (http://localhost:3000/static/js/1.chunk.js:75357:17) at Object.next (http://localhost:3000/static/js/1.chunk.js:75288:14) at fulfilled (http://localhost:3000/static/js/1.chunk.js:75243:24)

alexandrtovmach commented 3 years ago

@AbdulAhad125 Could you check with latest version?

alexandrtovmach commented 3 years ago

@AbdulAhad125 Feel free to reopen if issue still exist