You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/includes/desktop-app/quickstart-nodejs-electron.md
+4-7Lines changed: 4 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ To register your application and add the app's registration information to your
38
38
1. Select **Register** to create the application.
39
39
1. Under **Manage**, select **Authentication**.
40
40
1. Select **Add a platform** > **Mobile and desktop applications**.
41
-
1. In the **Redirect URIs** section, enter the redirect URI suggested by the app registration portal, e.g. `msalfa29b4c9-7675-4b61-8a0a-bf7b2b4fda91://auth`.
41
+
1. In the **Redirect URIs** section, enter `http://localhost`.
42
42
1. Select **Configure**.
43
43
44
44
#### Step 2: Download the Electron sample project
@@ -62,7 +62,7 @@ Your file should look similar to below:
62
62
63
63
```javascript
64
64
constAAD_ENDPOINT_HOST="https://login.microsoftonline.com/"; // include the trailing slash
@@ -121,7 +118,7 @@ Your file should look similar to below:
121
118
122
119
### How the sample works
123
120
124
-
When a user selects the **Sign In** button for the first time, get `getTokenInteractive` method of *AuthProvider.js* is called. This method redirects the user to sign-in with the *Microsoft identity platform endpoint* and validate the user's credentials, and then obtains an **authorization code**. This code is then exchanged for an access token using the `acquireTokenByCode` method of MSAL Node.
121
+
When a user selects the **Sign In** button for the first time, `acquireTokenInteractive` method of MSAL Node is called. This method redirects the user to sign-in with the *Microsoft identity platform endpoint*, obtains an **authorization code**, and then exchanges it for an access token.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/quickstart-v2-nodejs-desktop.md
+19-84Lines changed: 19 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,94 +108,29 @@ ms.custom: mode-api
108
108
>
109
109
> ### Requesting tokens
110
110
>
111
-
> In the first leg of authorization code flow with PKCE, prepare and send an authorization code request with the appropriate parameters. Then, in the second leg of the flow, listen for the authorization code response. Once the code is obtained, exchange it to obtain a token.
111
+
> You can use MSAL Node's acquireTokenInteractive public API to acquire tokens via an external user-agent such as the default system browser.
112
112
>
113
113
> ```javascript
114
-
> // The redirect URI you setup during app registration with a custom file protocol "msal"
115
-
> const redirectUri = "msal://redirect";
116
-
>
117
-
> const cryptoProvider = new CryptoProvider();
118
-
>
119
-
> const pkceCodes = {
120
-
> challengeMethod: "S256", // Use SHA256 Algorithm
121
-
> verifier: "", // Generate a code verifier for the Auth Code Request first
122
-
> challenge: "" // Generate a code challenge from the previously generated code verifier
123
-
> };
124
-
>
125
-
> /**
126
-
> * Starts an interactive token request
127
-
> * @param {object} authWindow: Electron window object
128
-
> * @param {object} tokenRequest: token request object with scopes
> successTemplate: '<h1>Successfully signed in!</h1> <p>You can close this window now.</p>',
125
+
> failureTemplate: '<h1>Oops! Something went wrong</h1> <p>Check the console for more information.</p>',
126
+
> });
127
+
>
128
+
> return authResponse;
129
+
> } catch (error) {
130
+
> throw error;
192
131
> }
193
132
> ```
194
-
>
195
-
> >|Where:| Description |
196
-
> >|---------|---------|
197
-
> >|`authWindow`| Current Electron window in process. |
198
-
> >|`tokenRequest`| Contains the scopes being requested, such as `"User.Read"`for Microsoft Graph or `"api://<Application ID>/access_as_user"`for custom web APIs. |
Copy file name to clipboardExpand all lines: articles/active-directory/develop/tutorial-v2-nodejs-desktop.md
+14-37Lines changed: 14 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,9 +40,9 @@ First, complete the steps in [Register an application with the Microsoft identit
40
40
Use the following settings for your app registration:
41
41
42
42
- Name: `ElectronDesktopApp` (suggested)
43
-
- Supported account types: **Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)**
43
+
- Supported account types: **Accounts in my organizational directory only (single tenant)**
44
44
- Platform type: **Mobile and desktop applications**
This preload script exposes a renderer methods to give the renderer process controlled access to some `Node APIs` by applying IPC channels that have been configured for communication between the main and renderer processes.
79
+
This preload script exposes a renderer API to give the renderer process controlled access to some `Node APIs` by applying IPC channels that have been configured for communication between the main and renderer processes.
80
80
81
-
6. Next, create *UIManager.js* class inside the *App* folder and add the following code:
*CustomProtocolListener* class can be instantiated in order to register and unregister a custom typed protocol on which MSAL Node can listen for Auth Code responses.
90
-
91
-
8. Finally, create a file named *constants.js* that will store the strings constants for describing the application **events**:
81
+
6. Finally, create a file named *constants.js* that will store the strings constants for describing the application **events**:
In the code snippet above, we first initialized MSAL Node `PublicClientApplication` by passing a configuration object (`msalConfig`). We then exposed `login`, `logout` and `getToken` methods to be called by main module (*main.js*). In `login` and `getToken`, we acquire ID and access tokens, respectively, by first requesting an authorization code and then exchanging this with a token using MSAL Node `acquireTokenByCode` public API.
107
+
In the code snippet above, we first initialized MSAL Node `PublicClientApplication` by passing a configuration object (`msalConfig`). We then exposed `login`, `logout` and `getToken` methods to be called by main module (*main.js*). In `login` and `getToken`, we acquire ID and access tokensusing MSAL Node `acquireTokenInteractive` public API.
120
108
121
-
## Add a method to call a web API
109
+
## Add Microsoft Graph SDK
122
110
123
-
Create another file named *fetch.js*. This file will contain an Axios HTTP client for making REST calls to the Microsoft Graph API.
111
+
Create a file named *graph.js*. The *graph.js* file will contain an instance of the Microsoft Graph SDK Client to facilitate accessing data on the Microsoft Graph API, using the access token obtained by MSAL Node:
Finally, create an environment file to store the app registration details that will be used when acquiring tokens. To do so, create a file named *authConfig.js* inside the root folder of the sample (*ElectronDesktopApp*), and add the following code:
117
+
Create an environment file to store the app registration details that will be used when acquiring tokens. To do so, create a file named *authConfig.js* inside the root folder of the sample (*ElectronDesktopApp*), and add the following code:
@@ -141,7 +129,6 @@ Fill in these details with the values you obtain from Azure app registration por
141
129
- `Enter_the_Cloud_Instance_Id_Here`: The Azure cloud instance in which your application is registered.
142
130
- For the main (or *global*) Azure cloud, enter `https://login.microsoftonline.com/`.
143
131
- For **national** clouds (for example, China), you can find appropriate values in [National clouds](authentication-national-cloud.md).
144
-
- `Enter_the_Redirect_Uri_Here`: The Redirect Uri of the application you registered `msal{Your_Application/Client_Id}:///auth`.
145
132
- `Enter_the_Graph_Endpoint_Here` is the instance of the Microsoft Graph API the application should communicate with.
146
133
- For the **global** Microsoft Graph API endpoint, replace both instances of this string with `https://graph.microsoft.com/`.
147
134
- For endpoints in **national** cloud deployments, see [National cloud deployments](/graph/deployments) in the Microsoft Graph documentation.
@@ -170,23 +157,13 @@ If you consent to the requested permissions, the web applications displays your
170
157
171
158
## Test web API call
172
159
173
-
After you sign in, select **See Profile** to view the user profile information returned in the response from the call to the Microsoft Graph API:
160
+
After you sign in, select **See Profile** to view the user profile information returned in the response from the call to the Microsoft Graph API. After consent, you'll view the profile information returned in the response:
174
161
175
162
:::image type="content" source="media/tutorial-v2-nodejs-desktop/desktop-04-profile.png" alt-text="profile information from Microsoft Graph":::
176
163
177
-
Select **Read Mails** to view the messages in user's account. You'll be presented with a consent screen:
178
-
179
-
:::image type="content" source="media/tutorial-v2-nodejs-desktop/desktop-05-consent-mail.png" alt-text="consent screen for read.mail permission":::
180
-
181
-
After consent, you'll view the messages returned in the response from the call to the Microsoft Graph API:
182
-
183
-
:::image type="content" source="media/tutorial-v2-nodejs-desktop/desktop-06-mails.png" alt-text="mail information from Microsoft Graph":::
184
-
185
164
## How the application works
186
165
187
-
When a user selects the **Sign In** button for the first time, get `getTokenInteractive` method of *AuthProvider.js* is called. This method redirects the user to sign-in with the Microsoft identity platform endpoint and validates the user's credentials, and then obtains an **authorization code**. This code is then exchanged for an access token using `acquireTokenByCode` public API of MSAL Node.
188
-
189
-
At this point, a PKCE-protected authorization code is sent to the CORS-protected token endpoint and is exchanged for tokens. An ID token, access token, and refresh token are received by your application and processed by MSAL Node, and the information contained in the tokens is cached.
166
+
When a user selects the **Sign In** button for the first time, the `acquireTokenInteractive` method of MSAL Node. This method redirects the user to sign-in with the Microsoft identity platform endpoint and validates the user's credentials, obtains an **authorization code** and then exchanges that code for an ID token, access token, and refresh token. MSAL Node also caches these tokens for future use.
190
167
191
168
The ID token contains basic information about the user, like their display name. The access token has a limited lifetime and expires after 24 hours. If you plan to use these tokens for accessing protected resource, your back-end server *must* validate it to guarantee the token was issued to a valid user for your application.
When Azure AD organizations in separate Microsoft Azure clouds need to collaborate, they can use Microsoft cloud settings to enable Azure AD B2B collaboration. B2B collaboration is available between the following global and sovereign Microsoft Azure clouds:
23
23
24
-
- Microsoft Azure global cloud and Microsoft Azure Government
25
-
- Microsoft Azure global cloud and Microsoft Azure China 21Vianet
24
+
- Microsoft Azure commercial cloud and Microsoft Azure Government
25
+
- Microsoft Azure commercial cloud and Microsoft Azure China 21Vianet
26
26
27
27
To set up B2B collaboration between partner organizations in different Microsoft Azure clouds, each partner mutually agrees to configure B2B collaboration with each other. In each organization, an admin completes the following steps:
28
28
@@ -74,12 +74,31 @@ Follow these steps to add the tenant you want to collaborate with to your Organi
74
74
75
75

76
76
77
-
78
77
1. If you want to change the cross-tenant access settings for this organization, select the **Inherited from default** link under the **Inbound access** or **Outbound access** column. Then follow the detailed steps in these sections:
After enabling collaboration with an organization from a different Microsoft cloud, cross-cloud Azure AD guest users can now sign in to your multi-tenant or Microsoft first-party apps by using a [common endpoint](redemption-experience.md#redemption-and-sign-in-through-a-common-endpoint) (in other words, a general app URL that doesn't include your tenant context). During the sign-in process, the guest user chooses **Sign-in options**, and then selects **Sign in to an organization**. The user then types the name of your organization and continues signing in using their Azure AD credentials.
85
+
86
+
Cross-cloud Azure AD guest users can also use application endpoints that include your tenant information, for example:
You can also give cross-cloud Azure AD guest users a direct link to an application or resource by including your tenant information, for example `https://myapps.microsoft.com/signin/Twitter/<application ID?tenantId=<your tenant ID>`.
93
+
94
+
## Supported scenarios with cross-cloud Azure AD guest users
95
+
96
+
The following scenarios are supported when collaborating with an organization from a different Microsoft cloud:
97
+
98
+
- Use B2B collaboration to invite a user in the partner tenant to access resources in your organization, including web line-of-business apps, SaaS apps, and SharePoint Online sites, documents, and files.
99
+
- Use B2B collaboration to [share Power BI content to a user in the partner tenant](/power-bi/enterprise/service-admin-azure-ad-b2b#cross-cloud-b2b).
100
+
- Apply Conditional Access policies to the B2B collaboration user and opt to trust multi-factor authentication or device claims (compliant claims and hybrid Azure AD joined claims) from the user’s home tenant.
101
+
83
102
## Next steps
84
103
85
104
See [Configure external collaboration settings](external-collaboration-settings-configure.md) for B2B collaboration with non-Azure AD identities, social identities, and non-IT managed external accounts.
0 commit comments