gpt4 book ai didi

android - OAuth 请求 token = android 应用程序中的 null

转载 作者:行者123 更新时间:2023-11-29 02:16:58 24 4
gpt4 key购买 nike

我正在尝试使用 OAuth 对某些内容(在本例中为 LinkedIn)进行身份验证,但请求的 token 始终返回 null?

下面是我的代码:

public void authenticateAppOauthApi() {
Log.d(TAG, "authenticateAppOauthApi");

OAuthServiceProvider provider = new OAuthServiceProvider(
REQUEST_TOKEN_PATH, AUTHORIZE_PATH, ACCESS_TOKEN_PATH);

OAuthConsumer consumer = new OAuthConsumer(CALLBACK_URL, API_KEY,
SECRET_KEY, provider);

OAuthAccessor accessor = new OAuthAccessor(consumer);

Intent intent = new Intent(Intent.ACTION_VIEW);
Log.d(TAG, "Intent intent = new Intent(Intent.ACTION_VIEW );");
// intent.setData(Uri.parse(url));
String url = accessor.consumer.serviceProvider.userAuthorizationURL
+ "?oauth_token=" + accessor.requestToken + "&oauth_callback="
+ accessor.consumer.callbackURL;

intent.setData(Uri.parse(url));
Log.d(TAG, "intent.setData(Uri.parse(url)); = " + url);
mContext.startActivity(intent);

Log.d(TAG, "finish authenticateApp");
}

我基本上按照这里的例子http://donpark.org/blog/2009/01/24/android-client-side-oauth

提前致谢

最佳答案

你可以试试这段代码。

OAuthClient oAuthClient = new OAuthClient(new HttpClient4());
try {
oAuthClient.getRequestToken(accessor);
} catch (IOException e) {
e.printStackTrace();
} catch (OAuthException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}

关于android - OAuth 请求 token = android 应用程序中的 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2975596/

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