Get Current Member Profile

Gets the profile of the current authenticated member. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-current-members-profile)

Script linkedin Verified

by hugo697 ยท 7/17/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 689 days ago
1
type Linkedin = {
2
	token: string
3
	apiVersion: string
4
}
5

6
export async function main(resource: Linkedin) {
7
	const endpoint = 'https://api.linkedin.com/rest/me'
8

9
	const response = await fetch(endpoint, {
10
		method: 'GET',
11
		headers: {
12
			Authorization: `Bearer ${resource.token}`,
13
			'LinkedIn-Version': `${resource.apiVersion}`,
14
			'X-Restli-Protocol-Version': '2.0.0'
15
		}
16
	})
17

18
	if (!response.ok) {
19
		throw new Error(`HTTP error! status: ${response.status}`)
20
	}
21

22
	const data = await response.json()
23

24
	return data
25
}
26