【问题标题】:Linkedin authentication using AngularJS Satellizer module使用 AngularJS Satellizer 模块的 Linkedin 身份验证
【发布时间】:2018-02-16 14:59:17
【问题描述】:

我正在使用 Satellizer 模块进行社交登录和注册。 我能够对 Instagram 进行身份验证,但在 Linkedin 身份验证过程中,出现以下错误 -

{ 
  error_description: 'missing required parameters, includes an invalid parameter value, parameter more than once. : client_secret',
  error: 'invalid_request' 
}

我检查了很多次,但无法解决这个问题。 下面是我正在使用的代码 -

var accessTokenUrl = 'https://www.linkedin.com/uas/oauth2/accessToken';
var peopleApiUrl = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,picture-url,headline,location,industry,summary,specialties,positions,picture-urls::(original))';

var params = {
    client_id: req.body.clientId,
    client_secret: CLIENT_SECRET,
    code: req.body.code,
    redirect_uri: req.body.redirectUri,
    grant_type: 'authorization_code'
};
request.post(accessTokenUrl, {form: params, json: true }, function (err, response, body) {

    if (response.statusCode !== 200) {
        return res.status(response.statusCode).send({message: body.error_description});
    }
    var params = {
        oauth2_access_token: body.access_token,
        format: 'json'
    };
  // Other relevant code
 });

【问题讨论】:

    标签: javascript angularjs linkedin satellizer


    【解决方案1】:

    尝试对请求 Content-Type: application/x-www-form-urlencoded 使用设置内容类型标头。

    来自LinkedIn

    POST /oauth/v2/accessToken HTTP/1.1
        Host: www.linkedin.com
        Content-Type: application/x-www-form-urlencoded
    
        grant_type=authorization_code&code=987654321&redirect_uri=https%3A%2F%2Fwww.myapp.com%2Fauth%2Flinkedin&client_id=123456789&client_secret=shhdonottell
    

    【讨论】:

    • 根据 Nodejs link 的请求模块,由于我在帖子中使用“表单”,它应该自动添加该标题。
    • json:true, json - sets body to JSON representation of value and adds Content-type: application/json header. Additionally, parses the response body as JSON. 可能有问题
    • 是的,改变了配置,它工作了。感谢支持
    猜你喜欢
    • 2016-10-10
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 2015-10-28
    • 2016-12-31
    • 1970-01-01
    • 2017-10-13
    相关资源
    最近更新 更多