Connecting to Google via OAuth 2 "Invalid parameter value for redirect_uri: Missing authority:"

I am trying to connect to Google through OAuth2. I am using code that works in another application, so I am pretty sure that the problem is with the configuration on Google.

I registered the client ID and secret key in the Google console, which I added to the authorization configuration:

var client = new GoogleOAuth2Client("[client id].apps.googleusercontent.com", "[secret key]");
var extraData = new Dictionary<string, object>();
OAuthWebSecurity.RegisterClient(client, "Google", extraData);

Unfortunately, when I click the button to connect, I get the following error:

  1. This is mistake.

    Error: invalid_request

    Invalid parameter value for redirect_uri: No authority: file: /// Account / ExternalLoginCallback% 3FReturnUrl = /

    Request details
    scope = https://www.googleapis.com/auth/userinfo.profile
    https: // www. googleapis.com/auth/userinfo.email
    response_type = code
    redirect_uri = File: /// Account / ExternalLoginCallback% 3FReturnUrl = /
    state = provider = Google & s.d.strong> = [number] client_id = [client id] .apps.googleuserconte

I tried changing the localhost parameter in the file /etc/hoststo other base URLs, and I added these places to redirect the URIs in Google Console as follows:

http://localhost:8080/Account/ExternalLoginCallback%3FReturnUrl=/ 
http://localhost.example.com:8080/Account/ExternalLoginCallback
http://localhost.example.com:8080/Account/ExternalLoginCallback%3FReturnUrl=/

. , , , - .

+4
1

redirect_uri , Google , , API Google. :

file:///Account/ExternalLoginCallback%3FReturnUrl=/

, .

http://localhost:8080/Account/ExternalLoginCallback%3FReturnUrl=/

URL :

http%3A%2F%2Flocalhost%3A8080%2FAccount%2FExternalLoginCallback%253FReturnUrl%3D%2F

. : https://github.com/mj1856/DotNetOpenAuth.GoogleOAuth2/blob/master/DotNetOpenAuth.GoogleOAuth2/GoogleOAuth2Client.cs

+6

Source: https://habr.com/ru/post/1568912/


All Articles