gpt4 book ai didi

android - Stocktwits API - AuthorizationCodeGrant HttpResponseException : 400 Bad Request

转载 作者:行者123 更新时间:2023-11-29 00:36:01 25 4
gpt4 key购买 nike

在 oauth2 舞蹈的第 1 步之后,我可以在重定向 URL 中检索代码。这很好用。但是,

我遇到“com.google.api.client.http.HttpResponseException: 400 Bad Request”错误

正在尝试获取 accessTokenResponse。知道为什么吗?

AuthorizationCodeGrant request = new AuthorizationCodeGrant(new NetHttpTransport(),
new JacksonFactory(),
OAuth2ClientCredentials.ACCESS_TOKEN_URL,
OAuth2ClientCredentials.CLIENT_ID,
OAuth2ClientCredentials.CLIENT_SECRET,
code,
OAuth2ClientCredentials.REDIRECT_URI);

try {
AccessTokenResponse accessTokenResponse = request.execute();
CredentialStore credentialStore = new SharedPreferencesCredentialStore(prefs);
credentialStore.write(accessTokenResponse );
} catch (IOException e) {
Log.e(TAG, "error= "+e);
e.printStackTrace();
}

这是触发错误的行:

AccessTokenResponse accessTokenResponse = request.execute();

我正在使用“com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.AuthorizationCodeGrant”

我应该使用其他东西吗?有什么建议吗?

最佳答案

参见 authorization flow 的第 5 步或 oauth/token end-point .

您似乎缺少 grant_type。

关于android - Stocktwits API - AuthorizationCodeGrant HttpResponseException : 400 Bad Request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12640800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com