gpt4 book ai didi

android - Linkedin 一旦通过身份验证 : while calling Url of user Profile again ask for authentication

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:00:48 25 4
gpt4 key购买 nike

我正在使用 LinkedIn-j API 进行 LinkedIn 集成。我可以发布状态更新。我希望在 Android 的 WebView 中显示用户配置文件,为此我使用以下代码获取用户公共(public) URL。

person.getSiteStandardProfileRequest().getUrl();

返回类似这样的内容 http://www.linkedin.com/profileviewProfile=&key=100652876&authToken=AWW7&authType=name&trk=api*a169149*s177398*

如果我要在 WebView 中打开此 url,然后将其重定向到 LinkedIn 登录页面,并在填写凭据后我可以看到用户配置文件

我想在不输入凭据的情况下打开用户配置文件,再次

我也尝试通过附加

URL&accesstoken="tokenIdReturned by Application"; 

但我仍然无法直接打开用户配置文件。我缺少什么?

最佳答案

我有相同的要求,我已经完成了两件事。

首先我使用我自己的 WebView 加载不同的 URL 来验证和显示配置文件。我已经将我的 WebView 设置为 public static 我已将调用重定向到 Activity 中我自己的 WebView 而不是使用默认浏览器

其次 我已经设置了 webview.getSettings().setAppCacheEnabled(true); 所以现在在查看配置文件时不再要求登录。

我已在 Manifest.xml 文件中将我的 Activity 声明为 singleInstace

更新:

我在 Activity 中使用 WebView 的方式。

public static WebView WV = null;
String uri;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv);
if (WV == null) {
WV = (WebView) findViewById(R.id.webView1);
WV.getSettings().setJavaScriptEnabled(true);
WV.getSettings().setAppCacheEnabled(true); // the important change
WV.getSettings().setSupportZoom(true);
WV.getSettings().setBuiltInZoomControls(true);
}

final SharedPreferences pref = getSharedPreferences(OAUTH_PREF,
MODE_PRIVATE);
final String token = pref.getString(PREF_TOKEN, null);
final String tokenSecret = pref.getString(PREF_TOKENSECRET, null);
if (token == null || tokenSecret == null) {
startAutheniticate();
} else {
showCurrentUser(new LinkedInAccessToken(token, tokenSecret));
}

}


void startAutheniticate() {
final LinkedInRequestToken liToken = oAuthService
.getOAuthRequestToken(OAUTH_CALLBACK_URL);
uri = liToken.getAuthorizationUrl();
getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit()
.putString(PREF_REQTOKENSECRET, liToken.getTokenSecret())
.commit();
WV.loadUrl(uri);
}

void showCurrentUser(final LinkedInAccessToken accessToken) {
// code to get Profile object using Linkedin-J API
//which is already available on the API site as Example

WV.loadUrl(profile.getSiteStandardProfileRequest().getUrl());
}

关于android - Linkedin 一旦通过身份验证 : while calling Url of user Profile again ask for authentication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10030122/

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