GmailApiQuickstart -

◇◆丶佛笑我妖孽 提交于 2019-12-03 10:52:45
Andy

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!