невозможно аутентифицировать Google Calendar API V3 с помощью OAuth 2.0 и веб-службы - PullRequest
0 голосов
/ 19 сентября 2018

Я новичок в этом.Я не могу пройти проверку подлинности с помощью службы веб-клиента c # .net.Может быть, я делаю что-то не так.

Вот Credentials.json

{
  "web": {
    "client_id": "1078513092554-scaalvk0kmvivq9nrd6gag7gkhqud0l9.apps.googleusercontent.com",
    "project_id": "claritysoft---go-1536637808216",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://www.googleapis.com/oauth2/v3/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "<My_Client_Secret>",
    "redirect_uris": [ "http://localhost:51454/customize/dialogs/api_settings/googlecalendar.aspx" ],
    "javascript_origins": [ "http://localhost:51454" ]
  }
}

Обратите внимание: URI перенаправления в консоли API: - http://localhost:51454/customize/dialogs/api_settings/googlecalendar.aspx

Теперь код C # .net для аутентификации -

public void LogIn()
{
    string db = Common.DBName; 
    string userid = Common.LoggedInUserId;
    UserCredential credential;
    using (
    var stream = new FileStream(SavedCredentialJsonPath, 
        FileMode.Open, 
        FileAccess.Read)
    ){
    string credPath = SavedTokenPath
          .Replace("{$DB_NAME$}",db.ToLower())
          .Replace("{$USER_ID$}", userid.ToLower());
    credential = 
          GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"projjwalkmaiti@gmail.com",
CancellationToken.None,
new FileDataStore(credPath, true)
).Result;
}
google_credentials = credential;
}

Но я получаю следующую ошибку от Google (код ошибки 400) URI перенаправления в запросе http://127.0.0.1:57014/authorize/, несовпадают с авторизованными для клиента OAuth.Чтобы обновить авторизованные URI перенаправления, посетите: https://console.developers.google.com/apis/credentials/oauthclient/1078513092554-scaalvk0kmvivq9nrd6gag7gkhqud0l9.apps.googleusercontent.com?project=1078513092554

Любая помощь приветствуется.Заранее спасибо!

...