Exemple #1
0
        private static async Task AcquireTokenAsync()
        {
            var    tokenCache           = new TokenCache();
            var    clientId             = "c00e9d32-3c8d-4a7d-832b-029040e7db99";
            var    resource             = "https://api.aadrm.com/";
            string redirectUri          = "com.microsoft.azip://authorize";
            string extraQueryParameters = "msafed=0";


            AuthenticationContext context = new AuthenticationContext("https://login.windows.net/common", tokenCache);
            var result = await context.AcquireTokenAsyncEx(
                resource,
                clientId,
                new Uri(redirectUri),
                new PlatformParameters(PromptBehavior.Always),
                UserIdentifier.AnyUser,
                extraQueryParameters);


            string token = result.AccessToken;

            Console.WriteLine(token + "\n");
        }