How to use OAuth 2.0 with @azure/msal-react package?
See original GitHub issueLibrary
-
msal@1.x.x
or@azure/msal@1.x.x
-
@azure/msal-browser@2.x.x
-
@azure/msal-node@1.x.x
-
@azure/msal-react@1.x.x
-
@azure/msal-angular@0.x.x
-
@azure/msal-angular@1.x.x
-
@azure/msal-angular@2.x.x
-
@azure/msal-angularjs@1.x.x
Description
Hi All,
After successfully imposing MSAL to my page, I was asked to add an OAuth2 into my application.
Isn’t @azure/msal-react capable of it? Thanks.
Reference of my index.js
import React from 'react';
import ReactDOM from 'react-dom';
import 'index.css';
import App from 'App';
import * as serviceWorker from 'serviceWorker';
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import reducer from 'store/reducer'
import { MsalProvider, MsalAuthenticationTemplate } from "@azure/msal-react";
import { Configuration, PublicClientApplication, InteractionType } from "@azure/msal-browser";
//, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
const store = createStore(reducer);
const config = {
auth: {
clientId: '***********************',
authority: 'https://login.microsoftonline.com/***********************' **// <-- isn't replacing the OAuth 2 endpoint here?**
},
cache: {
cacheLocation: "sessionStorage", // This configures where your cache will be stored
storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
}
};
const pca = new PublicClientApplication(config);
ReactDOM.render(
<Provider store={store}>
{/* <React.StrictMode> */}
<MsalProvider instance={pca}>
<MsalAuthenticationTemplate
interactionType={InteractionType.Redirect}>
<App/>
</MsalAuthenticationTemplate>
</MsalProvider>
</Provider>,
document.getElementById('root')
);
serviceWorker.unregister();
Source
- Internal (Microsoft)
- Customer request
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Tutorial: Create a React single-page app that uses auth code ...
In the Redirect URI: MSAL.js 2.0 with auth code flow step, enter http://localhost:3000 , the default location where create-react-app will serve ...
Read more >@azure/msal-react - npm
Start using @azure/msal-react in your project by running `npm i ... This version of the library uses the OAuth 2.0 Authorization Code Flow ......
Read more >Using MSAL.js to integrate React Single-page ... - YouTube
This month's in-depth topic: Deep dive on using MSAL.js to integrate React Single-page applications with Azure Active Directory.
Read more >Calling Microsoft Graph using @azure/msal-react from PCF ...
MSAL 2.x – Implements OAuth 2.0 Authorization Code Flow with PKCE ... the @azure/msal-react npm package to call Microsoft Graph to do a ......
Read more >@azure/msal-react examples - CodeSandbox
Learn how to use @azure/msal-react by viewing and forking ... React single-page application calling Microsoft Graph API using MSAL.js (w/ AAD v2 endpoint)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wy10cheng this is done for you by the library. The library abstracts the protocol away from the application and exposes APIs to acquire the ID and access tokens needed for your app to function. Please go through the docs and samples for msal-browser and msal-react, it should make it more apparent how to use this library.
@wy10cheng I’m not sure what you are asking. OAuth 2.0 is the protocol implemented by MSAL.js libraries. Specifically, msal-react and msal-browser are implementing the OAuth 2.0 authorization code flow with PKCE. If you’d like to read more about what the OAuth 2.0 protocol describes you can read more here.