Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

403 error when using google authentication #818

Closed
Strandedpirate opened this issue May 15, 2016 · 2 comments
Closed

403 error when using google authentication #818

Strandedpirate opened this issue May 15, 2016 · 2 comments

Comments

@Strandedpirate
Copy link

Strandedpirate commented May 15, 2016

Getting a 403 forbidden error while using the google authentication when the EnsureSuccessStatusCode method is called. I get to the "allow" screen on google's side, I grant my app access to my account but then it bombs out after redirecting back to my app. I tried setting the TokenEndpoint to "https://accounts.google.com/o/oauth2/token" instead of the hard-coded default but it didn't help; same error.

What else can I try to resolve this?

The facebook authentication has the same status code check and it is working just fine.

My setup:

app.UseGoogleAuthentication(new Microsoft.AspNet.Authentication.Google.GoogleOptions
{
    SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme,
    ClientId = Configuration["OAuth:google:clientid"],
    ClientSecret = Configuration["OAuth:google:clientsecret"],
    CallbackPath = new PathString(Configuration["OAuth:google:callbackpath"]),
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
});

Error:

An unhandled exception has occurred: Response status code does not indicate success: 403 (Forbidden).
      System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
         at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
         at Microsoft.AspNet.Authentication.Google.GoogleHandler.<CreateTicketAsync>d__1.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Authentication.OAuth.OAuthHandler`1.<HandleRemoteAuthenticateAsync>d__6.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Authentication.RemoteAuthenticationHandler`1.<HandleRemoteCallbackAsync>d__1.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Authentication.RemoteAuthenticationHandler`1.<HandleRequestAsync>d__0.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Microsoft.AspNet.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Microsoft.AspNet.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Microsoft.AspNet.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
@Tratcher
Copy link
Member

This is probobly a duplicate of #53

@Strandedpirate
Copy link
Author

Thanks, for me it was a simple matter of enabling Google+ API.

https://console.developers.google.com/apis
Google+ API > Enable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants