Beispiel #1
0
        public void Revoke()
        {
            var revocationApiClient = ApiClientProvider.GetApiClient <RevocationApi>();

            revocationApiClient.Configuration.Username = Config.ApiClientId;
            revocationApiClient.Configuration.Password = Config.ClientSecret;
            revocationApiClient.RevokeToken(Token);
        }
Beispiel #2
0
        public static AccessToken GetAccessToken(string authCode, string redirectUrl = null, string apiClientId = null, string clientSecret = null)
        {
            var accessToken = new AccessToken();

            accessToken.ApiClientId  = apiClientId ?? Config.ApiClientId;
            accessToken.ClientSecret = clientSecret ?? Config.ClientSecret;
            accessToken.RedirectUrl  = redirectUrl ?? Config.RedirectUrl;
            var tokenClient = ApiClientProvider.GetApiClient <TokenApi>();

            tokenClient.Configuration.Username = accessToken.ApiClientId;
            tokenClient.Configuration.Password = accessToken.ClientSecret;
            var resp = tokenClient.GenerateToken(AuthCodeGrantType, null, null, null, accessToken.RedirectUrl, authCode);

            accessToken.Token = resp?.AccessToken;
            return(accessToken);
        }
Beispiel #3
0
        public static AccessToken GetAccessToken(UserCredential credentials, string apiClientId = null, string clientSecret = null)
        {
            var accessToken = new AccessToken();

            if (credentials == null)
            {
                throw new ArgumentNullException();
            }
            //EST-2795 Allowing Username, password and instance id to read through config if not passed by caller
            credentials.UserName   = credentials.UserName ?? Config.Username;
            credentials.Password   = credentials.Password ?? Config.Password;
            credentials.InstanceId = credentials.InstanceId ?? Config.InstanceId;

            accessToken.ApiClientId  = apiClientId ?? Config.ApiClientId;
            accessToken.ClientSecret = clientSecret ?? Config.ClientSecret;
            var tokenClient = ApiClientProvider.GetApiClient <TokenApi>();

            tokenClient.Configuration.Username = accessToken.ApiClientId;
            tokenClient.Configuration.Password = accessToken.ClientSecret;
            var resp = tokenClient.GenerateToken(PasswordGrantType, credentials.UserNameRealm, credentials.Password, Scope);

            accessToken.Token = resp?.AccessToken;
            return(accessToken);
        }