예제 #1
0
        private static TokenModel ReNewToken(TokenRecord record)
        {
            _ActiveTokenList.Remove(record);
            record.Token = GetNewOAuthToken(record.TokenRequest);

            return(record.Token);
        }
예제 #2
0
        private static TokenModel GetNewOAuthToken(TokenRequestModel tokenRequest)
        {
            TokenRecord record = TokenGateway.GetNewOAuthToken(tokenRequest);

            _ActiveTokenList.Add(record);
            return(record.Token);
        }
예제 #3
0
        public static TokenRecord GetNewOAuthToken(TokenRequestModel tr)
        {
            RestClient client  = new RestSharp.RestClient(tr.TokenURL);
            var        request = new RestRequest(Method.POST);

            request.AddHeader("Accept", "application/json");
            request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            request.AddParameter("client_id", tr.OAuthCreds.ClientId);
            request.AddParameter("client_secret", tr.OAuthCreds.ClientSecret);
            if (!String.IsNullOrEmpty(tr.Scope))
            {
                request.AddParameter("scope", "GatewayAccess");
            }
            request.AddParameter("grant_type", "client_credentials");
            var        tResponse    = client.Execute(request);
            var        responseJson = tResponse.Content;
            TokenModel t            = TokenModel.TokenFromJson(responseJson);

            TokenRecord record = new TokenRecord(t, tr);

            return(record);
        }