Azure Native Client Authentication

I've created my own app on Azure, but I'm not sure how to get an access token with only tenant ID. I used to use a web app where I had a client id and passcode and I used that for authentication. I have tried using AcquireTokenSilentlyAsync, but I can't seem to get it done.

+3


source to share


1 answer


You can use the AcquireToken method as shown below. A browser dialog box will appear asking for your credentials.

private static string GetToken(string authority, string clientId, string redirectUri)
{
    var authContext = new AuthenticationContext(authority, validateAuthority: false);
    var result = authContext.AcquireToken("https://graph.windows.net",
        clientId, new Uri(redirectUri), PromptBehavior.Auto);

    return result.AccessToken;
}

      



If you want to authenticate without prompting for a user, see Granting permission to grant resource owner rights. This is explained in this article by Vittorio Bertocci.

+1


source







All Articles