GmailApiQuickstart -

后端 未结 2 2050
失恋的感觉
失恋的感觉 2021-02-12 16:46

I am embarrassed that I\'m simply failing with an example piece of code, but I\'ll blame it on the fact that it is late...

I have taken a copy and paste of: https://deve

相关标签:
2条回答
  • 2021-02-12 16:59

    here is a working example of non-interactive auth for Google Non-interactive authorization with Google OAuth2 the problem is not in "web" tag in the client json, but rather in the fact that their example is for web authentication while their suggested way of generating credentials is for non-interactive "service account". they have multiple problems with their documentation.

    0 讨论(0)
  • Right, after some more research (asking a colleague/genius), I found the problem. Basically the GoogleClientSecrets object was not being properly bound with the information from my client_secrets.json file. This meant that during authentication, objects were null resulting in the IllegalArgumentException.

    So the original file which looked like this:

    {
          "private_key_id": "zzz",
          "private_key": "-----BEGIN PRIVATE KEY-----\nxyz\n-----END PRIVATE KEY-----\n",
          "client_email": "1234@developer.gserviceaccount.com",
          "client_id": "1wdfghyjmp.apps.googleusercontent.com",
          "type": "service_account"
    }
    

    was edited to look like this:

    {
        "web" : {
          "private_key_id": "zzz",
          "private_key": "-----BEGIN PRIVATE KEY-----\nxyz\n-----END PRIVATE KEY-----\n",
          "client_email": "1234@developer.gserviceaccount.com",
          "client_id": "1wdfghyjmp.apps.googleusercontent.com",
          "type": "service_account"
        }
    }
    

    This allowed me to progress through the code with authentication.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题