Skip to content

Commit a87ab6f

Browse files
felix-dumitflovilmart
authored andcommitted
Support for validating LinkedIn SDK access_tokens (#2486)
1 parent cbcd44b commit a87ab6f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/authDataManager/linkedin.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Parse = require('parse/node').Parse;
44

55
// Returns a promise that fulfills iff this user id is valid.
66
function validateAuthData(authData) {
7-
return request('people/~:(id)', authData.access_token)
7+
return request('people/~:(id)', authData.access_token, authData.is_mobile_sdk)
88
.then((data) => {
99
if (data && data.id == authData.id) {
1010
return;
@@ -21,15 +21,21 @@ function validateAppId() {
2121
}
2222

2323
// A promisey wrapper for api requests
24-
function request(path, access_token) {
24+
function request(path, access_token, is_mobile_sdk) {
25+
var headers = {
26+
'Authorization': 'Bearer ' + access_token,
27+
'x-li-format': 'json',
28+
}
29+
30+
if(is_mobile_sdk) {
31+
headers['x-li-src'] = 'msdk';
32+
}
33+
2534
return new Promise(function(resolve, reject) {
2635
https.get({
2736
host: 'api.linkedin.com',
2837
path: '/v1/' + path,
29-
headers: {
30-
'Authorization': 'Bearer '+access_token,
31-
'x-li-format': 'json'
32-
}
38+
headers: headers
3339
}, function(res) {
3440
var data = '';
3541
res.on('data', function(chunk) {

0 commit comments

Comments
 (0)