LinkedIn profile fetching not working in asp.net - asp.net

I have integrated LinkedIn in my ASP.Net website and trying to read user profile data who logs in. I am accessing following URL but getting error. My application has authorized and got access token from LinkedIn.
URL
https://api.linkedin.com/v1/people/MyAccessToken
Error
The remote server returned an error: (401) Unauthorized.
It seems I am not using correct format to pass access token to this URL to get the data. Can someone please guide me on correct format.

the accesstoken should be added as an Bearer-Token and the API path should be :
https://api.linkedin.com/v1/people/person_ID/

Related

LinkedIn - Cannot create access token, Responded with "This application is not allowed to create application tokens". #linkedin

When trying to generate an access token in LinkedIn with my client id and silent secret I was responded with a message in JSON format saying:
This application is not allowed to create application tokens
I use v2 OAuth. App yet to be verified.
The documentation says that the access can only be enabled by LinkedIn itself and I couldn't find any documents that could tell me how to do that for now.
Kindly help me to generate the access token. #linkedin

Facebook OAuth Login via web api returns invalid_request

I am trying to use Facebook OAuth to authenticate user login in a asp.net web api app.
I am redirected to this page "https://www.facebook.com/common/invalid_request.php" get this error "Your request could not be processed.
Please try again" when logging in via the returned HTML from the ChallengeResult in the web api when hitting the api/Account/ExternalLogin endpoint.
I've already updated the Microsoft.Owin.Security.Facebook NuGet package in the web api but still having the error. I assume that this is a bug (thinking).
I've read an article about external OAuth authentication from:
http://bitoftech.net/2014/08/11/asp-net-web-api-2-external-logins-social-logins-facebook-google-angularjs-app/ but I still get the error.
Any workaround with this? This is my first time working with this.

LinkedIn - Access

A few years ago I signed up as a LinkedIn developer, registered an application and received my Client ID and Secret.
Using OAuth2, when I attempt to get an access token I get an error message saying "OAuth2 access is denied."
I've checked all the settings in my developer account and cannot see anything wrong, so I don't know why access is denied.
RESOLVED: I discovered that if I untick all of the Default Application Permissions with the exception of "r_basicprofile", I no longer get the OAuth2 access denied error.

Linkedin authentication error via api

We tried to authenticate via linkedin api , it throws error as
"Invalid http request". Please check the attachement.
FYI: Its already worked properly , but now we don't why not working suddenly.error

ASP.NET Web API 2: How do I log in with external authentication services?

According to this post http://www.asp.net/web-api/overview/security/external-authentication-services...
I'm able to log in with a local authentication service (with the new ASP.NET identity framework)
but I can't find a walkthrough to properly call (from a mobile app or Postman) the default web API generated in the Visual Studio 2013 SPA template.
Can anyone help me?
I had the same problem today and found the following solution:
At first get all available providers
GET /api/Account/ExternalLogins?returnUrl=%2F&generateState=true
The response message is a list in json format
[{"name":"Facebook",
"url":"/api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A15359%2F&state=QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1",
"state":"QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1"}]
Now send a GET request to the url of the provider you want to use. You will be redirected to the login page of the external provider. Fill in your credentials and the you will be redirected back to your site. Now parse the access_token from the url.
http://localhost:15359/#access_token=[..]&token_type=bearer&expires_in=[..]&state=QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1
If the user already has a local account, the .AspNet.Cookies cookie is set and you are done. If not, only the .AspNet.ExternalCookie cookie is set and you have to register a local account.
There is an api to find out if the user is registered:
GET /api/Account/UserInfo
The response is
{"userName":"xxx","hasRegistered":false,"loginProvider":"Facebook"}
To create a local account for the user, call
POST /api/Account/RegisterExternal
Authorization: Bearer VPcd1RQ4X... (access_token from url)
Content-Type: application/json
{"UserName":"myusername"}
Now send the same request with the provider url as before
GET /api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A15359%2F&state=QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1
But this time the user already has an account and gets authenticated. You can verify this by calling /api/Account/UserInfo again.
Now extract the access_token from the url. You have to add the Authorization: Bearer [access_token] header to every request you make.
I found another post showing pretty details how this external authentication works. The client is WPF and server uses ASP.NET Identity.
For those trying to use Web Api 2 External Login with Facebook in Android App this post is explaining only the first part of what we have to do. Here is a very explanatory link of the whole picture:
[Authenticated access to WebAPI via Facebook token from Android App

Resources