Example #1
0
 public Tokens RefreshToken(Client client, Token refreshToken)
 {
     var tokenCache = new TokenCache();
     var authenticationContext = new AuthenticationContext(AuthorityUri, tokenCache);
     var result = authenticationContext.AcquireTokenByRefreshToken(refreshToken, client, ResourceUri);
     var tokens = new Tokens
     {
         AccessToken = result.AccessToken,
         RefreshToken = result.RefreshToken,
         ExpiresOn = result.ExpiresOn
     };
     return tokens;
 }
Example #2
0
#pragma warning disable 1591 // Xml Comments
        public Tokens GetTokens(Client client)
        {
            var tokenCache = new TokenCache();
            var authenticationContext = new AuthenticationContext(AuthorityUri, tokenCache);
            var result = authenticationContext.AcquireToken(ResourceUri, client, new Uri(RedirectUri), PromptBehavior.RefreshSession);

            var tokens = new Tokens
            {
                AccessToken = result.AccessToken,
                RefreshToken = result.RefreshToken,
                ExpiresOn = result.ExpiresOn
            };

            return tokens;
        }
Example #3
0
        public Tokens GetTokens(Client client, ClientSecret clientSecret, Token token, string redirectUri)
        {
            var tokenCache = new TokenCache();

            var authenticationContext = new AuthenticationContext(AuthorityUri, tokenCache);
            var clientCredential = new ClientCredential(client, clientSecret);

            var result = authenticationContext.AcquireTokenByAuthorizationCode(token, new Uri(redirectUri), clientCredential);
            var tokens = new Tokens
            {
                AccessToken = result.AccessToken,
                RefreshToken = result.RefreshToken,
                ExpiresOn = result.ExpiresOn
            };
            return tokens;
        }