예제 #1
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);
        }
예제 #2
0
 private static void LogInfo(string message, TokenRequestModel tokenRequest)
 {
     //Infrastructure.LoggingService.Information(message, logger, tokenRequest.RequestId);
 }
예제 #3
0
 //private readonly static NLog.Logger logger;
 public static TokenModel GetCurrentOAuthToken(TokenRequestModel tokenRequest)
 {
     return(GetOAuthToken(tokenRequest));
 }
예제 #4
0
 public TokenRecord(TokenModel token, TokenRequestModel request)
 {
     Token        = token;
     Expires      = DateTime.Now.AddSeconds(token.ExpiresIn);
     TokenRequest = request;
 }