1

I'm trying to really "hash out" what's going on when I use OAuth (actually using it for Google only), but I just can't quite seem to understand the difference between:

OAuthWebSecurity.RequestAuthentication("Google", Href("~/Account/RegisterService.cshtml"));

And:

OAuthWebSecurity.VerifyAuthentication(Href("~/Account/RegisterService.cshtml"));

At "http://msdn.microsoft.com" They describe the difference as:

RequestAuthentication():

Requests the specified provider to start the authentication by directing users to an external website, and directs the provider to redirect the user to the specified URL when authentication is successful.

(Found Here: http://msdn.microsoft.com/en-us/library/microsoft.web.webpages.oauth.oauthwebsecurity.requestauthentication(v=vs.111).aspx)

And VerifyAuthentication():

Returns a value that indicates whether the user account has been confirmed by the provider.

(Found Here: http://msdn.microsoft.com/en-us/library/microsoft.web.webpages.oauth.oauthwebsecurity.verifyauthentication(v=vs.111).aspx)

So, I guess the question comes down to what the difference between their meanings of "authenticated" and "confirmed" are.

VoidKing
  • 6,282
  • 9
  • 49
  • 81
  • 1
    http://stackoverflow.com/a/15276169/340760 – BrunoLM Dec 05 '13 at 22:15
  • Thank you @BrunoLM that was very helpful. So, they `RequestAuthentication()` to get the response from Google, then I `VerifyAuthentication()` myself by testing against the response from Google? – VoidKing Dec 05 '13 at 22:30

1 Answers1

2

RequestAuthentication is going to redirect the user to the website and ask for the login. Once the credentials are entered and permission granted for your application it is going back to your website (returnUrl).

Once it comes back you should use VerifyAuthentication to validate the tokens returned by the provider.

var result = OAuthWebSecurity.VerifyAuthentication();

if (result.IsSuccessful)
{
    var provider = result.Provider;
    var uniqueUserID = result.ProviderUserId;
}

So RequestAuthentication is called when the user should be redirected to the provider to login/grant access. (User Login & Consent)

And VerifyAuthentication is the validation part just bellow.

img

BrunoLM
  • 97,872
  • 84
  • 296
  • 452
  • Sry it took so long to respond back. We had a storm come through Oklahoma and I've been out for a day and a half, in addition to the weekend. I'm looking over this now. – VoidKing Dec 09 '13 at 21:33