我使用这些链接link1,link2通过我的Android应用中的链接登录。我还在linkedin开发者上创建了我的应用,并提供了oauth的链接2.0和javascript。通过在link2中运行代码:
final Activity thisActivity = this;
findViewById(R.id.btnLiSignIn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LISessionManager.getInstance(getApplicationContext()).init(thisActivity, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
// Authentication was successful. You can now do
// other calls with the SDK.
Log.d(TAG, "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString());
Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();
}
@Override
public void onAuthError(LIAuthError error) {
// Handle authentication errors
Log.d(TAG, "failed " + error.toString());
Toast.makeText(getApplicationContext(), "failed " + error.toString(), Toast.LENGTH_LONG).show();
}
}, true);
}
});
我正在登录并获取访问令牌。我想向我的网站服务器发送访问令牌,并从我的网站获取用户数据。当我发送此令牌时,它无效。我是否需要获得其他令牌。请一步一步指导。
答案 0 :(得分:5)
你无法做到。来自documentation:
移动与服务器端访问令牌
重要的是要注意通过网站获取的访问令牌 Mobile SDK仅可用于Mobile SDK,不能用于 进行服务器端REST API调用。
同样,访问您已经存储在用户中的令牌 使用服务器端REST API调用进行身份验证将无法正常工作 使用Mobile SDK。
而是在设备上获取所需信息并将信息发送到您的服务器。