Google Calendar API - PHP

后端 未结 2 1438
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 04:57

I am currently using the Google Calendar API for a web application. However, every hour, I am prompted with a link to verify quickstart access. Does anyone know how to fix t

2条回答
  •  星月不相逢
    2021-01-19 05:53

    Here's a working example that generates the authentication object using the Service Account's JSON file

    $client = new Google\Client();
    $client->setApplicationName(APP_NAME);
    $client->setAuthConfig(PATH_TO_JSON_FILE);
    $client->setScopes(['YOUR_SCOPE1','YOUR_SCOPE2']);
    $client->setSubject(EMAIL_OF_PERSON_YOURE_IMPERSONATING);
    $client->setAccessType('offline');
    
    $service = new Google_Service_Drive($client);
    // Do stuff with the $service object
    
    1. Generate Service Account in Google API Console
    2. Delegate domain wide authority to that Service Account's Client ID in Google workspace and define the scopes that the Service Account will have access to
    3. Use the code above and make sure to include one more more relevant scopes

提交回复
热议问题