![]() * metadata discovery calls, thereby improving performance of token acquisition process. * make a request to the relevant endpoints to retrieve the metadata. * If the current msal configuration does not have cloudDiscoveryMetadata or authorityMetadata, we will * By default, MSAL Node will add OIDC scopes to the auth code request. * By default, MSAL Node will add OIDC scopes to the auth code url request. SuccessRedirect: options.successRedirect || '/', ![]() * You can pass the user's state in the app, such as the page or view they were on, as input to this parameter.Ĭonst state = 64Encode( * The state parameter can also be used to encode information of the app's state before redirect. * MSAL Node library allows you to pass your custom state as state parameter in the Request object. This.cryptoProvider = new msal.CryptoProvider() Require('dotenv').config( = require('./authConfig') Once created, add the following code there: Next, create a file named authConfig.js in the root of your project for reading in these parameters.Choose a random string of characters to replace this string with, such as your client secret. Enter_the_Express_Session_Secret_Here the secret used to sign the Express session cookie. ![]() For the main (global) Microsoft Graph API service, enter (include the trailing forward-slash). Enter_the_Graph_Endpoint_Here: The Microsoft Graph API cloud instance that your app will call.Use certificate credentials instead of client secrets in your confidential client applications, especially those apps you intend to deploy to production. This article uses a plaintext client secret for simplicity only. To generate a new key, use Certificates & secrets in the app registration settings in the Azure portal.Īny plaintext secret in source code poses an increased security risk. Enter_the_Client_secret: Replace this value with the client secret you created earlier.Enter_the_Application_Id_Here: The Application (client) ID of the application you registered.To restrict support to personal Microsoft accounts only, replace this value with consumers.If your application supports accounts in any organizational directory and personal Microsoft accounts, replace this value with common.If your application supports accounts in any organizational directory, replace this value with organizations.If your application supports accounts in this organizational directory, replace this value with the Tenant ID or Tenant name.Enter_the_Tenant_Info_here should be one of the following parameters:.For national clouds (for example, China), you can find appropriate values in National clouds.For the main (or global) Azure cloud, enter (include the trailing forward-slash).Enter_the_Cloud_Instance_Id_Here: The Azure cloud instance in which your application is registered.REDIRECT_URI=" POST_LOGOUT_REDIRECT_URI=" GRAPH_API_ENDPOINT="Enter_the_Graph_Endpoint_Here" # graph api endpoint string should end with a trailing slashĮXPRESS_SESSION_SECRET="Enter_the_Express_Session_Secret_Here"įill in these details with the values you obtain from Azure app registration portal: Then add the following code:ĬLOUD_INSTANCE="Enter_the_Cloud_Instance_Id_Here" # cloud instance string should end with a trailing slashĬLIENT_ID="Enter_the_Application_Id_Here"ĬLIENT_SECRET="Enter_the_Client_Secret_Here" env.dev file in the root of your project folder. Install these via npm: npm install -save express-session dotenv axios The web app sample in this tutorial uses the express-session package for session management, dotenv package for reading environment parameters during development, and axios for making network calls to the Microsoft Graph API. Locate the root of your project directory in a terminal and install the MSAL Node package via npm. The file and folder structure of your project should look similar to the following folder structure: ExpressWebApp/ ![]() ![]() Then, create an application skeleton as follows:Įxpress -view=hbs /ExpressWebApp & cd /ExpressWebApp.First, install the express-generator package:.Use the Express application generator tool to create an application skeleton. Client secret: ********* (record this value for use in a later step - it's shown only once).Supported account types: Accounts in this organizational directory only.Use the following settings for your app registration: Visual Studio Code or another code editorįirst, complete the steps in Register an application with the Microsoft identity platform to register your app.Install the authentication library packagesįor more information, see the sample code that shows how to use MSAL Node to sign in, sign out and acquire an access token for a protected resource such as Microsoft Graph.Register the application in the Azure portal. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |