shawnmclean / Mandrill-dotnet

.NET wrapper for Mandrill
Other
202 stars 107 forks source link

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

Open psdongre313 opened 5 years ago

psdongre313 commented 5 years ago

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;
    }
UmutComlekci commented 4 years ago

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

teengineer commented 2 years ago

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