0

Ich habe Google Kalender API-Projekt eingerichtet. Ich verwende OAuth 2.0 für den Zugriff auf Google Kalender APIs-Daten mit dem Zustimmungsbildschirm.Nicht autorisierte Google Kalender API (Google_Service_Exception)

ich den Prozess hier erwähnt verfolgt habe: https://developers.google.com/google-apps/calendar/quickstart/php

, während ich alle Kalender für das autorisierte Google-Konto zu holen versuchen. Ich erhalte folgende Fehlermeldung:

<h1>Google_Service_Exception</h1> 
{ 
"error": "unauthorized_client", 
"error_description": "Unauthorized" 
} 

Hier ist der Code alle Kalenderliste zu holen:

$client = $this->getGoogleCalenderClient($clientSecretPath); 

$accessToken = json_decode(file_get_contents($clientSecretPath), true); 

$client->setAccessToken($accessToken); 

if ($client->isAccessTokenExpired()) { 

    $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); 
    $result = $s3Client->putObject([ 
     'Bucket' => $bucketName, 
     'Key' => $credentialsPath, 
     'Body' => json_encode($client->getAccessToken()) 
    ]); 
} 

$service = new Google_Service_Calendar($client); 

$calendarList = $service->calendarList->listCalendarList(); 


Weiß jemand, was dies hier geschieht? Und wie kann ich diesen Fehler beheben?
Dankbar für jede Hilfe.

Antwort

0

Does anyone know what this is happening here? And how can I fix this error?

Wenn Sie die Anwendung mit Dienstkonto zugreifen,

Kontrolle dieses Github und das offizielle Dokument von Google for domain-wide delegation.

  1. Go to your Google Apps domain’s Admin console.
  2. Select Security from the list of controls. If you don't see Security listed, select More controls from the gray bar at the bottom of the page, then select Security from the list of controls. If you can't see the controls, make sure you're signed in as an administrator for the domain.
  3. Select Advanced settings from the list of options.
  4. Select Manage third party OAuth Client access in the Authentication section.
  5. In the Client name field enter the service account's Client ID.
  6. In the One or More API Scopes field enter the list of scopes that your application should be granted access to. For example, if your application needs domain-wide access to the Google Drive API and the Google Calendar API, enter: https://www.googleapis.com/auth/drive , https://www.googleapis.com/auth/calendar .
  7. Click Authorize.
:

Die folgenden Schritte müssen von einem Administrator der Google Apps-Domain durchgeführt werden