RaviSoni-Systematix Ответов: 0

Ошибка авторизации ошибка 400: redirect_uri_mismatch в Google drive api


Authorization Error Error 400: redirect_uri_mismatch The redirect URI in the request, http://127.0.0.1:57916/authorize/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}

We are getting Authorization Error everytime.When we run the google drive web site intregation code at localhost it will give the Error 400: redirect_uri_mismatch after all configuration at google developer console account.And when we published this code at iis it give No response.


2020-11-10_19-28-43[^]

public static Google.Apis.Drive.v3.DriveService GetService(string path)
{
UserCredential credential;
try
{
//getPath = IHostingEnvironment .ContentRootPath + "\\Content\\";
//get Credentials from client_secret.json file

string FolderPath = path;
//var CSPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/");
string[] Scopes = new string[] { DriveService.Scope.Drive };
using (var stream = new FileStream(Path.Combine(path, "shaApplication.json"), FileMode.Open, FileAccess.Read))
{
//String FolderPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/"); ;
String FilePath = Path.Combine(FolderPath, "DriveServiceCredentials.json");
//dsAuthorizationBroker.RedirectUri = "http://localhost:58196";

credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(FilePath, true)).Result;

}
}
catch(Exception ex)
{
throw new Exception(""+ex);
}
//create Drive API service.
Google.Apis.Drive.v3.DriveService service = new Google.Apis.Drive.v3.DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Web SHA Client",
});
return service;
}


Что я уже пробовал:

Я пробовал его с типом приложения desktop, он работает на локальной машине, но не на сервере. Когда я попробовал использовать приложение типа Web, оно также не работает на локальном компьютере.

Пожалуйста, помогите в этом.

0 Ответов