如何使用 ng2-cordova-oauth 连接到 linkedin?
How to connect to linkedin using ng2-cordova-oauth?
我正在尝试使用 ng2-cordova-oauth 使用 cordova 登录 linkedin。但我在尝试登录时遇到此错误:
The redirect_uri does not match the registered value.
这是我的 linkedin 提供商对象:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: "XXXX",
appScope: ["r_fullprofile"],
});
我是这样使用它的:
this.cordovaOauth.logInVia(this.linkedinProvider).then(success => {
console.log("RESULT: " + JSON.stringify(success));
}, error => {
console.log("ERROR: ", error);
});
问题是 linkedin 需要的其他参数不可用,即步骤 2 中提到的参数:https://developer.linkedin.com/docs/oauth2
我该如何添加和使用它们,facebook 示例只有这些参数,当我尝试添加任何 linkedin 参数时,出现编译错误:
const provider = new Facebook({
clientId: string,
appScope?: string[],
redirectUri?: string,
responseType?: string,
authType?: string
});
linkedin 提供商应如下所示:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: client_id,
appScope: ["r_basicprofile","r_emailaddress"],
redirectUri: redirectUri,
responseType: responseType,
state: state
});
responseType 始终等于 'code',redirectUri 始终等于“http://localhost/callback”。 state 是您随机生成的字符串值。
您会在您的 linkedin 应用程序页面中找到 client_id 和 client_secret 值。
"logInVia" 函数将 return 一个包含 authorization_code 的承诺,当您获得它时,您将需要获取访问令牌并使用它发出另一个请求以获取您想要的数据。
整个请求都记录在第 3 步和第 4 步中 here。
P.S:在第 4 步中,不要忘记授权 header 中访问令牌前的 "Bearer"。
我正在尝试使用 ng2-cordova-oauth 使用 cordova 登录 linkedin。但我在尝试登录时遇到此错误:
The redirect_uri does not match the registered value.
这是我的 linkedin 提供商对象:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: "XXXX",
appScope: ["r_fullprofile"],
});
我是这样使用它的:
this.cordovaOauth.logInVia(this.linkedinProvider).then(success => {
console.log("RESULT: " + JSON.stringify(success));
}, error => {
console.log("ERROR: ", error);
});
问题是 linkedin 需要的其他参数不可用,即步骤 2 中提到的参数:https://developer.linkedin.com/docs/oauth2
我该如何添加和使用它们,facebook 示例只有这些参数,当我尝试添加任何 linkedin 参数时,出现编译错误:
const provider = new Facebook({
clientId: string,
appScope?: string[],
redirectUri?: string,
responseType?: string,
authType?: string
});
linkedin 提供商应如下所示:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: client_id,
appScope: ["r_basicprofile","r_emailaddress"],
redirectUri: redirectUri,
responseType: responseType,
state: state
});
responseType 始终等于 'code',redirectUri 始终等于“http://localhost/callback”。 state 是您随机生成的字符串值。 您会在您的 linkedin 应用程序页面中找到 client_id 和 client_secret 值。 "logInVia" 函数将 return 一个包含 authorization_code 的承诺,当您获得它时,您将需要获取访问令牌并使用它发出另一个请求以获取您想要的数据。
整个请求都记录在第 3 步和第 4 步中 here。 P.S:在第 4 步中,不要忘记授权 header 中访问令牌前的 "Bearer"。