Creating a custom LinkedIn OAuth application
The step-by-step instructions below follow LinkedIn's documentation on setting up OAuth 2.0 for a web application.
Create credentials for ngrok
-
Navigate to the LinkedIn Developer Portal, sign in, click My apps on the top menu, and then click Create app.
-
Enter App name, select a LinkedIn Page, enter the Privacy policy URL in the corresponding fields, and then click Create app.
-
On the app page, click the Auth tab and make note of both the Client ID and Client Secret values.
-
Click the pencil icon for the Authorized redirect URLs in the OAuth 2.0 settings section, add the ngrok oauth callback URL (i.e.
https://idp.ngrok.com/oauth2/callback
), and then click Update. -
Click the Products tab, and then click Request access for Sign In with LinkedIn using OpenID Connect.
Update your ngrok endpoint traffic policy
- Access the ngrok Dashboard Endpoints page and locate an existing endpoint you'd like to add this to or create a new one.
- In your traffic policy, add the following configuration:
- YAML
- JSON
---
on_http_request:
- actions:
- type: oauth
config:
provider: linkedin
client_id: "{your app's oauth client id}"
client_secret: "{your app's oauth client secret}"
scopes:
- r_emailaddress
- r_liteprofile
{
"on_http_request": [
{
"actions": [
{
"type": "oauth",
"config": {
"provider": "linkedin",
"client_id": "{your app's oauth client id}",
"client_secret": "{your app's oauth client secret}",
"scopes": [
"r_emailaddress",
"r_liteprofile"
]
}
}
]
}
]
}
- Click Save to validate and update your traffic policy.
Configure access control
Optionally, configure access control to your service by only allowing specific users or domains. For example:
- YAML
- JSON
# Only allow access to me@example.com. Add this after your OAuth Action.
---
on_http_request:
- expressions:
- "!(actions.ngrok.oauth.identity.email in ['me@example.com'])"
actions:
- type: deny
// Only allow access to me@example.com. Add this after your OAuth Action.
{
"on_http_request": [
{
"expressions": [
"!(actions.ngrok.oauth.identity.email in ['me@example.com'])"
],
"actions": [
{
"type": "deny"
}
]
}
]
}