Google calendar api Push notification: 401 - Unauthorized WebHook callback channel

后端 未结 3 432
暗喜
暗喜 2021-01-07 01:18

Any solution for the issue. This seems to be not working

{
 \"error\": {
  \"errors\": [
   {
    \"domain\": \"global\",
    \"reason\": \"push.webhookUrlUn         


        
3条回答
  •  孤城傲影
    2021-01-07 01:20

    Push notifications require that you've verified domain ownership, so cannot be created in the API Explorer, as it doesn't provide a means of associating the requests with a project on which you've verified ownership. This can be done in the OAuth Playground, if you use project credentials, as detailed below:

    • Configure the API project:

      1. Access your API project at https://console.developers.google.com/project/.
      2. Ensure that you've registered the HTTPS version of your site according to the instructions at https://developers.google.com/admin-sdk/directory/v1/guides/push#registering-your-domain.
      3. From the Products & services menu (three horizontal lines at the top left), select ‘API Manager’, then the ‘Enabled APIs’ tab, and ensure that the appropriate API is enabled.
      4. Select ‘Credentials’, and from the ‘Add credentials’ drop down list, select ‘Oauth client ID’.
      5. If not previously configured, you’ll be prompted to configure the consent screen, so click ‘Configure consent screen.’ If so, enter your email address, a product name, and click ‘Save.’
      6. Select 'Web Application', and enter a Name for the client id.
      7. Under 'Authorized Javascript Origins' enter 'https://developers.google.com.'
      8. Under 'Authorised redirect URIs', enter 'https://developers.google.com/oauthplayground'.
      9. Click ‘Create Client ID’.
    • Configure the OAuth Playground:

      1. Navigate to https://developers.google.com/oauthplayground/.
      2. Click ‘OAuth 2.0 Configuration’ (gear icon) in the top right hand corner.
      3. Check ‘Use your own OAuth credentials’.
      4. Paste the ‘Client ID’ from the ‘Credentials’ page of your API project in to ‘OAuth Client ID’.
      5. Paste the ‘Client Secret’ from the ‘Credentials’ page of your API project in to ‘OAuth Client secret’.
      6. Click ‘Close.’
    • Authorize API requests:

      1. Enter https://www.googleapis.com/auth/admin.directory.user in ‘Input your own scopes’.
      2. Click ‘Authorize APIs’.
      3. You’ll be prompted to permit API access to your domain, so click ‘Allow access’.
      4. You’ll see the response ‘HTTP/1.1 302 Found.’ Click ‘Exchange authorization code for tokens’.
      5. You should see ‘HTTP/1.1 200 OK’. The page will drop down to the next section in a few moments.
      6. Select POST as the 'HTTP method.'
      7. Click 'Enter request body', and enter your request, for example:

        { "id": "c887ce64-adc8-4007-952c-a172c376b30d", "type": "web_hook", "address": "https://example.com/watch" }

      8. Click 'Close' when done.

      9. Enter the URI for the resource you want to monitor, replacing {calendarId} with the appropriate calendar ID, for example: https://www.googleapis.com/calendar/v3/calendars/user@example.com/events/watch
      10. Click 'Send the request.'

      11. You should receive a response similar to:

        { "resourceId": "DmuNd7MI-w7qwW1FxDNf_pdqk7Y", "kind": "api#channel", "expiration": "1507327087000", "id": "c887ce64-adc8-4007-952c-a172c376b30d", "resourceUri": "https://www.googleapis.com/calendar/v3/calendars/user@example.com/events?maxResults=250&alt=json" }

    Note: Push notifications for other APIs, for example the Directory API, may have additional parameters. Check the relevant Reference documentation for details.

提交回复
热议问题