I can't find anywhere how to set the OAuth2 redirect_uri in an ASP.NET 4.5 webforms application. By default it's set to localhost and of course I get this error from google:
The redirect URI in the request: http://localhost:3884/signin-google did not
match a registered redirect URI
And this from Facebook:
Given URL is not allowed by the Application configuration.: One or more of the
given URLs is not allowed by the App's settings. It must match the Website URL
or Canvas URL, or the domain must be a subdomain of one of the App's domains.
And I get this error from my website domain (not from the localhost).
The redirect_uri is an address used by OAuth providers as a location to deliver the access_token by means of a browser redirect. The popular OAuth provider Facebook has run into many vulnerabilities relating to OAuth redirection.
From the Firebase documentation: ... make sure your OAuth redirect URI (e.g. my-app-12345.firebaseapp.com/__/auth/handler) is listed as one of your OAuth redirect URIs in your Facebook app's settings page on the Facebook for Developers site in the Product Settings > Facebook Login config.
The redirect URL is the endpoint for your application or web page that processes the seller authorization response and manages the seller's OAuth tokens. You need to add this URL to your application using the Developer Dashboard.
OAuth provides client applications a "secure delegated access" to server resources on behalf of a resource owner. It specifies a process for resource owners to authorize third-party access to their server resources without sharing their credentials (from the Wikipedia). OAuth stands for Open Authorization.
I was testing the built in external login logic for authentication, and I got this error even though my Google API credentials were correct. For example the redirect URI was set to:
http://localhost:29405/signin-google
The odd thing was that the default CallbackPath for the Google Authentication is "/signin-google" but I had to set this anyway in App_Start/Startup.Auth, so I added this line and it worked:
CallbackPath = new PathString("/signin-google")
so...
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "YOUR CLIENT ID",
ClientSecret = "YOUR CLIENT SECRET",
CallbackPath = new PathString("/signin-google")
});
After looking at a lot of answers this is what worked for me:
The default redirect URI is /signin-google, so add this to the Authorized redirect URI.
Add this to the RouteConfig File:
routes.MapRoute(name: "signin-google", url: "signin-google", defaults: new { controller = "Account", action = "ExternalLoginCallback" });
Hope it helps anyone that cross by this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With