unauthorized_scope_error in LinkedIn oAuth2 authentication - oauth-2.0

I am following the official Microsoft instructions in Sign in with Linkedin (there are also the Linkedin instructions here), which also link here for the authorization code flow. As instructed, I have set up a linkedin application and used the client id and secret to initiate an oAuth 2 flow, requesting the r_liteprofile and r_emailaddress scopes.
Instead of getting the login form, I am redirected to my callback url with the following params:
error: unauthorized_scope_error
error_description: Scope "r_liteprofile" is not authorized for your application
state: cfa970987c9a3c2178dddeda0d81dab3e00dce4c683098d6
This is the list of default scopes (which, as per the documentation, are the ones granted if you don't specify a list of scopes yourself), and the r_liteprofile is not in there.
Is the documentation out of date, or am I overlooking something?

We have to enable "Sign In with LinkedIn" under the products tab, only then you can avail that scope (r_liteprofile and/or r_emailaddress) and services.
This goes for the review process(System takes max 60 mins to approve) and If your request has been approved, the relevant product will be moved to the "Added products" section.

This happened to me the other day but somehow I was able to get around the issue. The new Microsoft API docs for LinkedIn are up to date. The docs on LinkedIn Developers portal will soon be outdated:
Important update: All developers need to migrate to Version 2.0 of our APIs and OAuth 2.0 by March 1, 2019.
A few things to try:
Register a new LinkedIn OAuth 2.0 developer application - newly registered applications have access to the new V2 API
Try removing the r_liteprofile scope or revert back to r_basicprofile

My little contribution in 2021.
It seems like Linkedin keeps changing the value for scopes.
On the Linkedin developer portal looking under OAuth 2.0 scopes section in the Auth tab, I found the values that finally worked for me.
PS: Make sure to enable Sign-in from the product Tab.

Navigate to Products in the LinkedIn Developer Console and select Sign in with LinkedIn.
The verification process takes a few moments and then r_emailaddress and r_liteprofile should appear under your permissions.

Solution for me was to click "select" next to "Sign In with LinkedIn" on the LinkedIn developers console for my app.

We must add a product with Sign In with LinkedIn (click on select): Product menu with "Sign in with linkedin" selected.png.
Then, in the auth menu: OAuth 2.0 scopes, we get this : Auth menu scope.png

Related

IdentityServer4: How to show external providers consent screen?

Just recently starting using IdentityServer4 (IS4) playing around with samples and so on.
I have a setup where run IS4 (using the included sample UI MVC) configured with Google as an external provider. I also have an API setup, as well as a client (MVC web app). When authenticating, and the user clicks "Google" in the "External Login" section, he/she is redirected to Google as expected. However, after supplying the username and password, I expected to the see Google consent screen, but instead I am redirected back to the consent screen in IS4. Why is that? Should the end user not give consent that his/her Google profile information is being accessed, on a page which clearly is from Google (i.e. HTTPS and Googles certificate)?
I acknowledge that since I am also requiring consent from the user to access my API I might end up with 2 consent screens (one for profile info from Google, and one for API access from my own IS4 configuration), but if I did not have an API in my setup and simply wanted to use IS4 in a federated setup to provide ID tokens, I would not have a need for the consent of my own API and thus would expect only to see the consent screen from my external providers (e.g. Google, Facebook, Twitter, etc.).
I have my external provider configured like this:
services.AddAuthentication()
.AddGoogle("Google", options =>
{
options.ClientId = "<my client id>";
options.ClientSecret = "<my client secret>";
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
});
Could someone please enlighten me :-)
Thanks
From Google' help:
To set up your project's consent screen and request verification:
Go to the Google API Console OAuth consent screen page.
Add required information like a product name and support email address.
Click Add Scope.
On the dialog that appears, select the scopes your project uses. Sensitive scopes display a lock icon next to the API name.
To select scopes for registration, you need to enable the API, like Drive or Gmail, from APIs & Services > API Library.
You must select all scopes used by the project.
When you're finished adding details to the OAuth consent screen, click Submit for verification.
A Verification required window displays.
Add scopes justification, a contact email address, and any other information that can help the team with verification, then click Submit.
Note: The consent screen
settings within the console are set at the project level, so the
information that you specify on the Consent screen page applies across
the entire project.
So, what you need is to disable consent for your client in IdSrv and enable it in Google.
Additionally, as described in this answer,
By design, the consent screen is not shown in the scenario with account selection and profile/email scopes only requested..., since the account selection UI already shows the email and profile (name/picture) information that will be shared with the app.
As added by #Mike Wilcox:
When including a sensitive/restricted scope, if not verified for the scopes added, you will see a not verified screen during consent oauth flow. You can pass through by clicking advanced - > go to [app_name] (unsafe)
There is a playground: https://developers.google.com/oauthplayground/ where you can test this out.Click on the settings icon in the top right and then check the "Use your own OAuth Credentials" box to then enter your app creds. You can add scopes and test out there.
You don't have control when you redirect to external idp since it is a delegated authentication. I don't know how Google have implemented their OAuth flows but the following might be reasons as to why consent screen is not shown:
You are not requesting any scopes that require user consent
The user already gave consent to access to his/her info to your client (you should be able to check this in Google account pages)
Your client is configured to bypass consent screens (this is possible in IDS4 by setting RequireConsent flag to false, but I would doubt you can do this in Google as a 3rd party OAuth client)

Getting "FacebookAds::ClientError (Invalid parameter: Terms of Service Not Accepted (fbtrace_id: Ch/RdwGB+D3))" after i call api to create App

I will explain the scenarios here
1) When user click on link facebook button facebook permission dialog is bypassed and returns back directly on redirect uri(http://localhost:3000/ in my case) with code and state.
2) I am successfully able to exchange the code return above with access token.
3) I used facebooks access token debugger to analyze the token above and shows be proper scopes i need.
4) After this i fetch ad_accounts id, page token and page ids using this token.
5) when i use this token to create campaign for ads i get the following error.
FacebookAds::ClientError (Invalid parameter: Terms of Service Not Accepted (fbtrace_id: Ch/RdwGB+D3))
I use ruby facebook-business-sdk.
My app is in development mode and not live yet.
I can see both facebook login and marketing api green live in my app dashboard.
It makes sense to me that i am getting "Terms not accepted error" as user is never prompted to permissions dialog to permit my app for token.
I also observed that if add scope params to facebook login uri, the user is prompted to permission dialog.
I must be missing some configuration here, i have not yet submitted my app for review.
Any help/clue is appreciated.

How Can I Generate an Instagram Access Token Using their Implicit Flow?

I want to use the Instagram API to show my own content on my own website. I can see in their documentation that content owners can display up to 20 pieces of media on their site while the app is in Sandbox mode.
I've created an app on my account and I am trying to use their Client Side Implicit Authentication to generate an access_token.
I hit this URL and login to my account:
https://www.instagram.com/oauth/authorize/?client_id=MYCLIENTID&redirect_uri=www.mysite.com&response_type=token
When I submit the login form, I am brought to an Instagram 404 page that says:
Sorry, this page isn't available. The link you followed may be broken, or the page may have been removed. Go back to Instagram.
What am I missing? Do I even need an access_token? Before they changed their API last November I was able to use just the client_id in my requests. I suppose that's not possible anymore?
I think you need to include http://.../ for your redirect_uri. So it would be: https://www.instagram.com/oauth/authorize/?client_id=MYCLIENTID&redirect_uri=http://www.example.com/&response_type=token
But of course that means you will also need to add http://www.example.com/ as the Valid redirect URIs in "Manage Clients" on Instagram.

Linkedin: List of requested permissions does not change when the application asks user for permissions

I am using linkedin login for one of my websites, however regardless of what "members permission" (OAuth User Agreement) I set for my Linkedin application which used linkedin to login, when the user enters my application it only displays
The application like to acess some of your linkedin info:
1-YOUR PROFILE OVERVIEW
2-YOUR EMAIL ADDRESS
3- NETWORK UPDATES
I however want my application ask for
4- YOUR CONNECTIONS
as well!
But even if I select all the (member permissions [as show in image below]) it again only lists the three items above to the user! Any tips please?
You don't mention any language/library you're using. We use the ruby devise gem for LinkedIn Oauth which has a config setting for config.omniauth which is passed a scope, e.g.:
:scope => 'r_basicprofile r_emailaddress r_contactinfo r_network'
The LinkedIn API documents the passing of scope with you auth request here:
https://developer.linkedin.com/documents/authentication

How to delete Google App Engine OAuth 2.0 client ID?

I want to implement social media log-in feature to my site where I have to allow users to use their existing Google or Facebook credentials to log-in to my site.
I read some articles and found learned that for Google log-in, I need to use Google+ API. So I added some Javascript and HTML code in my HTML page and tried to log in but I am getting following error.
401. That’s an error.
Error: invalid_client
Application: mytestapplication
You can email the developer of this application at: shekhar#gmail.com
no registered origin
I tried to create new OAuth ID but already there are too many IDs and I am not able to delete any one of them. I have tried all the client-id present for this application but none of the client-id is working.
Can anyone please tell how do I implement sign-in with google feature? How to delete and create new client-id?
The last line is important:
no registered origin
On the API Credentials page, click Edit Settings under the Client ID for web application section. Put your URL there (http://example.com).

Resources