-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathget-profile.ts
More file actions
57 lines (50 loc) · 1.35 KB
/
get-profile.ts
File metadata and controls
57 lines (50 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Example call to fetch the member profile for the authorized member.
* The 3-legged member access token should include the 'r_liteprofile' scope, which
* is part of the Sign In With LinkedIn API product.
*/
import { RestliClient } from 'linkedin-api-client';
import dotenv from 'dotenv';
dotenv.config();
async function main(): Promise<void> {
const restliClient = new RestliClient();
restliClient.setDebugParams({ enabled: true });
const accessToken = process.env.ACCESS_TOKEN || '';
/**
* Basic usage
*/
let response = await restliClient.get({
resourcePath: '/me',
accessToken
});
console.log('Basic usage:', response.data);
/**
* With field projection to limit fields returned
*/
response = await restliClient.get({
resourcePath: '/me',
queryParams: {
fields: 'id,firstName,lastName'
},
accessToken
});
console.log('With field projections:', response.data);
/**
* With decoration of displayImage
*/
response = await restliClient.get({
resourcePath: '/me',
queryParams: {
projection: '(id,firstName,lastName,profilePicture(displayImage~:playableStreams))'
},
accessToken
});
console.log('With decoration:', response.data);
}
main()
.then(() => {
console.log('Completed');
})
.catch((error) => {
console.log(`Error encountered: ${error.message}`);
});