Mandrill-dotnet icon indicating copy to clipboard operation
Mandrill-dotnet copied to clipboard

Id = 14, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

Open psdongre313 opened this issue 6 years ago • 2 comments

I am trying to get AAD access token from Azure and i am getting WaitingForActivation message.. Am i doing something wrong.. Please help ... Thanks in Advance !!

public static async Task getAcccessTockenMs( string certificateLocation, string certificatePassword) { // AAD Instance string authority = "https://login.microsoftonline.com/{Tanent ID}";

        string clientId = "Client Application ID";
        string aadAudience = "https://login.microsoftonline.com/{Tanent ID}/oauth2/token";

        var authCtx = new AuthenticationContext(authority);
        // Load certificate from Disk
        X509Certificate2 clientCert = new X509Certificate2(certificateLocation, certificatePassword);
        
        var clientAssertion = new ClientAssertionCertificate(clientId, clientCert);

        var authenticationResult = await authCtx.AcquireTokenAsync(aadAudience, clientAssertion);

        if (authenticationResult == null)
        {
            throw new InvalidOperationException("Failed to obtain the token");
        }
        // contains the token
        string accessToken = authenticationResult.AccessToken;
        return accessToken;
    }

psdongre313 avatar Feb 13 '19 14:02 psdongre313

You need to use await keyword for async methods. You see this message because of Task doesn't run yet.

UmutComlekci avatar Feb 07 '20 13:02 UmutComlekci

You need to use await keyword for async methods. You see this message because of Task doesn't run yet.

thanks, i used it and it worked

teengineer avatar Dec 14 '21 10:12 teengineer