Uber-API Access_Token в ответе POST теперь кажется длиннее, чем раньше, как мне извлечь из него фактический Access_Token с помощью C#?

При попытке получить новый токен доступа, используя токен обновления из v2, я теперь получаю очень длинный токен, который выглядит как какой-то зашифрованный ключ. Изначально это был простой access_token почти такой же длины, что и refresh_token. Теперь это новый access_token, который будет использоваться при отправке запроса Uber от имени клиента? Или как получить фактический токен доступа, который я должен использовать в своем Uber-запросе, то есть тот, который раньше был почти такой же длины, что и токен обновления.

Ниже приведен скриншот ответа, который я получаю с помощью Почтальона.

ПОСТМАН Скриншот

Ниже приведен метод фрагмента исходного кода C#, который я вызываю для получения access_token.

        public async Task WebServerAsyncRefresh(string clientId, string clientSecret, string redirectUri, string RefreshToken)
    {
        if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException("clientId");
        if (string.IsNullOrEmpty(clientSecret)) throw new ArgumentNullException("clientSecret");
        if (string.IsNullOrEmpty(redirectUri)) throw new ArgumentNullException("redirectUri");
        if (string.IsNullOrEmpty(RefreshToken)) throw new ArgumentNullException("refreshToken");
        if (!Common.IsValidUri(redirectUri)) throw new ArgumentException("Invalid redirectUri");

        var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("grant_type", "refresh_token"),
                new KeyValuePair<string, string>("client_id", clientId),
                new KeyValuePair<string, string>("client_secret", clientSecret),
                new KeyValuePair<string, string>("redirect_uri", redirectUri),
                new KeyValuePair<string, string>("refresh_token", RefreshToken)
            });

        var request = new HttpRequestMessage()
        {
            Method = HttpMethod.Post,
            RequestUri = new Uri(TokenUrl),
            Content = content
        };

        var responseMessage = await _httpClient.SendAsync(request).ConfigureAwait(false);
        var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);

        if (responseMessage.IsSuccessStatusCode)
        {
            var authToken = JsonConvert.DeserializeObject<AuthToken>(response);

            AccessToken = authToken.access_token;
            RefreshToken = authToken.refresh_token;
        }
        else
        {
            //TODO: Create appropriate error response
            //var errorResponse = JsonConvert.DeserializeObject<AuthErrorResponse>(response);
            //throw new ForceAuthException(errorResponse.error, errorResponse.error_description);
            throw new Exception("error");
        }
    }

0 ответов

Другие вопросы по тегам