1
votes

I currently have authentication working (WebAPI OWIN) with grant_type=password&username=&password for my simple username/password combo and it returns me a Bearer token which is good.

Now I’m trying to implement it with social login but can’t get my head around it. I'm using ionic cloud to authenticate my linkedin social login from my app and when I try to log in, it's returning me a linkedIn token.

Now I have a linkedin token, how can I use this to validate against my WebAPI service so it returns me a Bearer token?

1
Did you figure out how to do it?Ciaran Gallagher
Ciaran, please see my answer below.DrZeuso

1 Answers

1
votes

Ok, so maybe this isn't the best way to do it and I'd like to see a better solution.

  1. So what I ended up doing is after my social login, it redirects me to my signin-linkedin redirect Url with OAuth 2.0 code.

  2. I call my WebAPI auth service passing through OAuth code from step 1.

  3. From my WebAPI, I call https://www.linkedin.com/oauth/v2/accessToken API with OAuth token from step 1 as 'code' parameter.

  4. This exchanges OAuth code for access_token, which I can use to get profile object - ie id, firstname, lastname, email etc.

  5. Then i use linkedin id against my db to get user's username/password.

  6. i call my OWIN WebAPI with grant_type=password along with username/password and I get my Bearer token which I can subsequently use to have user authenticated against my WebAPI.