Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Login Failure" using LinkedIn OAuth in asp.net mvc 4

I am taking a look at the default OAuth implementation that comes with asp.net mvc 4. It definitely is impressive, as all i had to do was add this line in AuthConfig.cs:

OAuthWebSecurity.RegisterLinkedInClient("_key_", "_secret_");

enabling above, did offer up the LinkedIn link to login. I was prompted for password once, but after entering it i got:

"Login Failure. Unsuccessful login with service."

, and have been getting this ever since w/out ever being prompted for password again.

It is not clear to me if this is due to initial bad credentials i entered, or something with the way i set up the key.

Also, i don't see the actual controller code anywhere within my app, so even if my login worked, it is not clear how i could obtain information from linked in.. i.e. history.

it is nice how easy this integration was, but I am leaning towards a more manual implementation of this?

however i can't help but wonder that above implementation probably also works.

UPDATE

i've traced the problem to be this call:

public ActionResult ExternalLogin(string provider, string returnUrl) {
    return new ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
}

callback comes back with "401 Unauthorized".. even though the credentials are correct. from what i can gather in other posts, this may be due to incorrectly formed headers by OAuth library?

like image 425
Sonic Soul Avatar asked Dec 15 '22 18:12

Sonic Soul


1 Answers

I had the same problem and it would appear that this is a bug.

See "Paul Roa" comments on this post:

http://blogs.msdn.com/b/webdev/archive/2012/08/15/oauth-openid-support-for-webforms-mvc-and-webpages.aspx?PageIndex=2

and then his solution (which works for me), here:

http://blog.mrroa.com/post/30454808112/asp-net-custom-linkedin-oauth-provider

like image 187
DazWilkin Avatar answered Dec 28 '22 12:12

DazWilkin