by Guest » 07 Jan 2025, 13:48
Derzeit wird ein alter asp.net-Code aktualisiert und Sie müssen den Autorisierungscode-Anbieter über
AuthorizationCodeCredential für Microsoft Graph verwenden. MS gab ein Beispiel:
https://learn.microsoft.com/en-us/graph ... s-provider.
Um diesen Anbieter nutzen zu können, muss ich den von einer Weiterleitung zurückgegebenen Autorisierungscode abrufen und übergeben. Dies ist der Teil, bei dem ich nicht sicher bin, wie ich an diesen Code komme, obwohl ich sehe, dass er im Browser zurückgegeben wird.
Code: Select all
// Values from app registration
var clientId = "YOUR_CLIENT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";
// For authorization code flow, the user signs into the Microsoft
// identity platform, and the browser is redirected back to your app
// with an authorization code in the query parameters
var authorizationCode = "HOW_DO_I_GET_THIS_CODE????";
// using Azure.Identity;
var options = new AuthorizationCodeCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
// https://learn.microsoft.com/dotnet/api/azure.identity.authorizationcodecredential
var authCodeCredential = new AuthorizationCodeCredential(
tenantId, clientId, clientSecret, authorizationCode, options);
Jede Hilfe wäre dankbar!
Derzeit wird ein alter asp.net-Code aktualisiert und Sie müssen den Autorisierungscode-Anbieter über [b]AuthorizationCodeCredential[/b] für Microsoft Graph verwenden. MS gab ein Beispiel: https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=csharp#client-credentials-provider.
Um diesen Anbieter nutzen zu können, muss ich den von einer Weiterleitung zurückgegebenen Autorisierungscode abrufen und übergeben. Dies ist der Teil, bei dem ich nicht sicher bin, wie ich an diesen Code komme, obwohl ich sehe, dass er im Browser zurückgegeben wird.
[code]// Values from app registration
var clientId = "YOUR_CLIENT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";
// For authorization code flow, the user signs into the Microsoft
// identity platform, and the browser is redirected back to your app
// with an authorization code in the query parameters
var authorizationCode = "HOW_DO_I_GET_THIS_CODE????";
// using Azure.Identity;
var options = new AuthorizationCodeCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
// https://learn.microsoft.com/dotnet/api/azure.identity.authorizationcodecredential
var authCodeCredential = new AuthorizationCodeCredential(
tenantId, clientId, clientSecret, authorizationCode, options);
[/code]
Jede Hilfe wäre dankbar!