Я пытаюсь аутентифицировать свое веб-приложение с помощью Google Plus API. В Google Developer console в разделе «Учетные данные» для моего Cliend Id for Web Application
.Google Authentication - ошибка redirect_uri_mismatch
я добавил следующие перенаправления URI: http://localhost:50883/oauth/add_oauth_token
Когда я запускаю мое приложение, я получаю следующее сообщение об ошибке:
400. That’s an error.
Error: redirect_uri_mismatch
Application: SID3
You can email the developer of this application at: [email protected]
The redirect URI in the request: http://localhost:55404/authorize/ did not match a registered redirect URI.
Learn more
Request Details
from_login=1
response_type=code
scope=https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
access_type=offline
redirect_uri=http://localhost:55404/authorize/
as=-45fed094242eac62
pli=1
client_id=389029010035-knoo3a2445r77pirc06h8fhgdc5q0dsv.apps.googleusercontent.com
authuser=0
hl=es
Так что для какой-либо причины Google меняет свое перенаправление URI в порт 55404, почему? , Большое спасибо и привет
Это код:
protected void LoginToGooglePlus(object sender, ImageClickEventArgs e)
{
PlusService service = null;
UserCredential credential = null;
string[] scopes = new string[] {PlusService.Scope.PlusLogin, PlusService.Scope.UserinfoEmail,
PlusService.Scope.UserinfoProfile};
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
try
{
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credentials;
using (var stream = new FileStream("C:\\Users\\Usuario\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\client_secret.json", FileMode.Open, FileAccess.Read))
{
credentials= GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes, Environment.UserName, CancellationToken.None, new FileDataStore("WebApplication1")).Result;
}
}
catch (Exception ex)
{
//If the user hits cancel you wont get access.
if (ex.InnerException.Message.IndexOf("access_denied") != -1)
{
Console.WriteLine("User declined access");
Console.ReadLine();
return;
}
else
{
Console.WriteLine("Unknown Authentication Error:" + ex.Message);
Console.ReadLine();
return;
}
}
// Now we create a Google service. All of our requests will be run though this.
service = new PlusService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "SID3",
});
}
JSON-файл, который я использую именно эти один:
{"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret":"jpkVDaaMjlLCHGh67DJ9Zv19","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":"[email protected]account.com","redirect_uris":["http://localhost:50880/Paneles.aspx"],"client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/[email protected]account.com","client_id":"389029010035-knoo3a2445r77pirc06h8fhgdc5q0dsv.apps.googleusercontent.com","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
Я не думаю, что Google меняет ваш порт. Думаю, ваш сеанс отладки asp меняет ваш порт. http://msdn.microsoft.com/en-us/library/ms178109(v=vs.100).aspx Перенаправление uri должно быть таким же, как и тот, к которому вы звоните. – DaImTo
Здравствуйте, Линда, я положил его на статический порт и ничего, он не работает, поэтому я не знаю, что делать. Спасибо – zoit
вам нужно будет написать свой код, я думаю. и попробуйте добавить полный файл в redirect uri http: // localhost: 50883/oauth/add_oauth_token/test.aspx – DaImTo