LinkedIn API v2 r_basicprofile权限403错误求助及权限获取咨询
Fixing LinkedIn API 403 with r_basicprofile & v2 /me Endpoint
First off, the 403 error you're hitting comes down to a critical mismatch: you're using a v1 permission scope (r_basicprofile) with a v2 API endpoint. LinkedIn's v2 API doesn't recognize v1 scopes at all—even if the user granted r_basicprofile, it won't grant access to v2 resources like the /me endpoint.
Key Context to Clear Up
r_basicprofile is a deprecated v1 scope. For v2 API requests, you need to use v2-compatible scopes tailored to the data you want:
r_liteprofile: Grants access to basic info (ID, first/last name, profile picture)r_profile:read: Grants access to full profile details including headline, experience, education, etc. (this is exactly what you need for the headline field)
Step-by-Step Solution
Update Your Authorization Scope
- Head to your LinkedIn Developer app > Auth > Scopes
- Remove
r_basicprofile(it’s irrelevant for v2 requests) - Add
r_profile:read(keepr_liteprofileif you still need basic profile data) - Save your changes
Re-Authenticate the User
- Your existing access token only has permissions from the old scope. You’ll need to redirect the user through the OAuth flow again to get a new access token that includes
r_profile:read.
- Your existing access token only has permissions from the old scope. You’ll need to redirect the user through the OAuth flow again to get a new access token that includes
Make the Corrected v2 API Request
- Use the new access token to call the
/meendpoint with a projection that explicitly includesheadline.
- Use the new access token to call the
C# Code Example
Here’s a practical implementation using HttpClient to fetch the profile with headline:
using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; class LinkedInProfileService { private readonly string _apiEndpoint = "https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,headline,profilePicture(displayImage~:playableStreams))"; public async Task<string> FetchFullProfileAsync(string accessToken) { using var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await httpClient.GetAsync(_apiEndpoint); if (response.IsSuccessStatusCode) { return await response.Content.ReadAsStringAsync(); } else { var errorDetails = await response.Content.ReadAsStringAsync(); throw new HttpRequestException($"Request failed: {response.StatusCode} - {errorDetails}"); } } // Quick usage example public static async Task Main() { var service = new LinkedInProfileService(); string validAccessToken = "YOUR_NEW_ACCESS_TOKEN_WITH_R_PROFILE_READ"; try { var profileJson = await service.FetchFullProfileAsync(validAccessToken); Console.WriteLine("Profile Data: " + profileJson); } catch (Exception ex) { Console.WriteLine("Error fetching profile: " + ex.Message); } } }
Quick Troubleshooting Tips
- Verify your access token’s scopes: You can check which scopes are attached to a token using LinkedIn’s token inspector in your developer dashboard.
- Production app restrictions: If you’re using this in a production app, some scopes (like
r_profile:read) may require LinkedIn’s review. For development/testing, you can use test users without needing approval.
内容的提问来源于stack exchange,提问作者CruzerEdge
相关产品推荐
相关产品推荐

