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/app-service/scenario-secure-app-access-microsoft-graph-as-app.md
+53-5Lines changed: 53 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,8 +116,9 @@ In **Overview**, select **Permissions**, and you'll see the added permissions fo
116
116
117
117
:::image type="content" alt-text="Screenshot that shows the Permissions pane." source="./media/scenario-secure-app-access-microsoft-graph/enterprise-apps-permissions.png":::
118
118
119
-
## Call Microsoft Graph (.NET)
119
+
## Call Microsoft Graph
120
120
121
+
# [C#](#tab/programming-language-csharp)
121
122
The [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) class is used to get a token credential for your code to authorize requests to Microsoft Graph. Create an instance of the [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) class, which uses the managed identity to fetch tokens and attach them to the service client. The following code example gets the authenticated token credential and uses it to create a service client object, which gets the users in the group.
122
123
123
124
To see this code as part of a sample application, see the [sample on GitHub](https://github.com/Azure-Samples/ms-identity-easyauth-dotnet-storage-graphapi/tree/main/3-WebApp-graphapi-managed-identity).
@@ -126,7 +127,7 @@ To see this code as part of a sample application, see the [sample on GitHub](htt
126
127
127
128
Install the [Microsoft.Identity.Web.MicrosoftGraph NuGet package](https://www.nuget.org/packages/Microsoft.Identity.Web.MicrosoftGraph) in your project by using the .NET Core command-line interface or the Package Manager Console in Visual Studio.
128
129
129
-
#[Command line](#tab/command-line)
130
+
#### .NET Core command-line
130
131
131
132
Open a command line, and switch to the directory that contains your project file.
Open the project/solution in Visual Studio, and open the console by using the **Tools** > **NuGet Package Manager** > **Package Manager Console** command.
@@ -204,6 +203,55 @@ public async Task OnGetAsync()
204
203
Users=msGraphUsers;
205
204
}
206
205
```
206
+
---
207
+
208
+
# [Node.js](#tab/programming-language-nodejs)
209
+
The call to Microsoft Graph is performed in the controllers/graphController.js file getUsersPage controller. The `DefaultAzureCredential` class from [@azure/identity](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md) package is used to get a token credential for your code to authorize requests to Azure Storage. Create an instance of the `DefaultAzureCredential` class, which uses the managed identity to fetch tokens and attach them to the service client. The following code example gets the authenticated token credential and uses it to create a service client object, which gets the users in the group.
210
+
211
+
To see this code as part of a sample application, see the [sample on GitHub](https://github.com/Azure-Samples/ms-identity-easyauth-nodejs-storage-graphapi/tree/main/3-WebApp-graphapi-managed-identity).
To query Microsoft Graph, the sample uses the [Microsoft Graph JavaScript SDK](https://github.com/microsoftgraph/msgraph-sdk-javascript). The code for this is located in utils/graphHelper.js:
240
+
241
+
```nodejs
242
+
getAuthenticatedClient = (accessToken) => {
243
+
// Initialize Graph client
244
+
const client = graph.Client.init({
245
+
// Use the provided access token to authenticate requests
0 commit comments