Пример #1
0
        public static async Task <OAuth2Token> RequestTokenAsync(string authorizationCode)
        {
            if (ClientId == null || ClientSecret == null || authorizationCode == null || RedirectUrl == null)
            {
                return(null);
            }

            logger.InfoExecutionStart("Requesting token"); //logging

            JObject jObject = JObject.FromObject(new
            {
                grant_type    = "authorization_code",
                client_id     = ClientId,
                client_secret = ClientSecret,
                code          = authorizationCode,
                redirect_uri  = RedirectUrl //need?
            });

            OAuth2Token = await PostAsync <OAuth2Token>("/oauth/token", jObject.ToString(), RequestVersion.SITE).ConfigureAwait(false);

            logger.InfoOrWarnExecutionStatus("Requesting token", IsAuthorized); //logging

            return(OAuth2Token);
        }