Ejemplo n.º 1
0
 private void ValidateAccessTokenErrorResponse(GenerateAccessTokenRs accessTokenRs)
 {
     if (accessTokenRs.ErrorCode != null)
     {
         throw new AuthenticationException(accessTokenRs.ErrorCode, accessTokenRs.Message);
     }
 }
Ejemplo n.º 2
0
        public static GenerateAccessTokenRs GetAccessToken(string appID, string appSecret, string refreshToken)
        {
            //preparing header
            NameValueCollection header = new NameValueCollection();

            header.Add(Constants.APPLICATION_ID_STRING, appID);
            header.Add(Constants.APPLICATION_SECRET_STRING, appSecret);
            header.Add(Constants.REFRESH_TOKEN_STRING, refreshToken);

            GenerateAccessTokenRs response = AsyncHelpers.RunSync <GenerateAccessTokenRs> (() => APICallHandler.GetAsync <GenerateAccessTokenRs>(header, string.Format(Constants.ACCESS_TOKEN_URL, Constants.API_ROOT)));

            return(response);
        }
Ejemplo n.º 3
0
        public string GenerateAccessToken()
        {
            GenerateAccessTokenRs accessTokenRs = AuthenticationService.GetAccessToken(ApplicationId, ApplicationSecret, RefreshToken);

            //Checking for Error response
            ValidateAccessTokenErrorResponse(accessTokenRs);
            this.AccessToken = accessTokenRs.AccessToken;
            this.ApiRoot     = accessTokenRs.EndpointUrl;
            if (!String.IsNullOrEmpty(accessTokenRs.RefreshToken))
            {
                this.RefreshToken = accessTokenRs.RefreshToken;
            }
            return(this.AccessToken);
        }