集成LinkedIn API获取企业帖子遇权限问题,求完整操作步骤
Hey there, let's work through fixing these two errors and walk you through the full end-to-end process for integrating the LinkedIn API to fetch your company's posts:
Step 1: Fix the "access_denied: This application is not allowed to create application tokens" Error
This error pops up because LinkedIn's Client Credentials Flow has strict prerequisites for apps:
- Your app must be linked to a verified company page: Head to the LinkedIn Developer Portal, navigate to your app, and find the "Company Pages" section. Link it to your business page—note that the page must already be verified by LinkedIn first.
- Enable the Client Credentials Flow: Go to your app's "Auth" > "OAuth 2.0 Settings" tab, and make sure the Client Credentials Flow option is turned on. If it's not available, you may need to submit a request to LinkedIn explaining your use case for this flow.
- Ensure your app isn't in Development mode: Only apps that are either approved or live can generate application tokens. Double-check your app's status in the developer portal.
The activityFeeds endpoint with the networkShares query requires the r_organization_social scope, which isn't available by default—you need to apply for it:
- Navigate to your app's "Products" page in the developer portal, find the "Marketing Developer Platform" product, and click "Request Access". Fill out the application with a clear, detailed explanation of why you need to fetch company posts (e.g., internal content analytics, cross-platform content aggregation).
- Wait for LinkedIn's review team to approve your request. Once approved, go to "Auth" > "Scopes" to confirm
r_organization_socialis added to your app's allowed scopes. - Important: Tokens generated via Client Credentials Flow can only access content from the company page(s) linked to your app—you won't be able to pull data from unlinked pages or personal profiles.
Full End-to-End Integration Steps
Let's put it all together into a complete workflow:
Create and configure your LinkedIn app
- Log into the LinkedIn Developer Portal and create a new app, filling in basic details like app name, contact email, and your company website.
- Link your verified company page: In the app's "Company Pages" tab, search for your business page and associate it with the app.
Request required products and permissions
- In the "Products" section of your app, submit a request for the "Marketing Developer Platform" (this is where the
r_organization_socialscope lives). - Enable the Client Credentials Flow in "Auth" > "OAuth 2.0 Settings" if it isn't already enabled.
- In the "Products" section of your app, submit a request for the "Marketing Developer Platform" (this is where the
Generate an access token
- Use the Client Credentials Flow to fetch a token with the
r_organization_socialscope. Here's the curl command to do this:POST https://www.linkedin.com/oauth/v2/accessToken --header "Content-Type: application/x-www-form-urlencoded" --data-urlencode "grant_type=client_credentials" --data-urlencode "client_id=YOUR_CLIENT_ID" --data-urlencode "client_secret=YOUR_CLIENT_SECRET" --data-urlencode "scope=r_organization_social" - You'll get a response containing your
access_token—save this for API calls.
- Use the Client Credentials Flow to fetch a token with the
Fetch company posts via the activityFeeds API
- Call the endpoint with your token and company ID (you can find your company ID in the URL of your LinkedIn company page, e.g.,
12345fromhttps://www.linkedin.com/company/12345/):GET https://api.linkedin.com/v2/activityFeeds?q=networkShares&owner=urn:li:organization:{YOUR_COMPANY_ID} --header "Authorization: Bearer YOUR_ACCESS_TOKEN" --header "Content-Type: application/json"
- Call the endpoint with your token and company ID (you can find your company ID in the URL of your LinkedIn company page, e.g.,
Parse and use the response
- The API returns a JSON object with post details like content text, publish timestamp, engagement metrics (likes, comments), and more. Extract the fields you need for your use case.
Quick Additional Tips
- Always make sure your use case aligns with LinkedIn's Developer Policies—avoid scraping or misusing data, as this can lead to app restrictions.
- If your permission request gets rejected, refine your explanation to be more specific about how you'll use the data and resubmit.
- Use LinkedIn's built-in Test Console in the Developer Portal to test token generation and API calls before integrating into your code.
内容的提问来源于stack exchange,提问作者Jitendra Rajput
相关产品推荐
相关产品推荐

