Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication.AdalTokenProvider.Renew C# (CSharp) Method

Renew() private method

private Renew ( AdalAccessToken token ) : void
token AdalAccessToken
return void
        private void Renew(AdalAccessToken token)
        {
            if (IsExpired(token))
            {
                var context = CreateContext(token.Configuration);
                try
                {
                    var authResult = context.AcquireTokenByRefreshToken(GetRefreshToken(token),
                        token.Configuration.ClientId,
                        token.Configuration.ResourceClientUri);
                    if (authResult == null)
                    {
                        throw new Exception(Resources.ExpiredRefreshToken);
                    }
                    token.AuthResult = authResult;
                }
                catch (Exception ex)
                {
                    throw new AadAuthenticationCantRenewException(Resources.ExpiredRefreshToken, ex);
                }
            }
        }

Usage Example

Example #1
0
 public void AuthorizeRequest(Action <string, string> authTokenSetter)
 {
     tokenProvider.Renew(this);
     authTokenSetter(AuthResult.AccessTokenType, AuthResult.AccessToken);
 }