Google OAuth2 Service Accounts authorization

让人想犯罪 __ 提交于 2019-12-11 04:24:38

问题


I'm trying to perform Google Drive API calls using "Service Accounts" authorization.

I'm calling the API, but files.list returns me empty set, meanwhile the drive is not empty. I guess I should specify prn field as well in order to perform call on behalf of the concrete user (I don't really get who is it called for when prn is not specified). The problem is that when I specify prn authorization returns me access_denied error.

{
  "error" : "access_denied"
}

Documentation says that I should enable client API access from control panel http://support.google.com/a/bin/answer.py?hl=en&answer=162106

Here is what I've done, but this doesn't help much, it still gives me access_denied.

What's wrong here?


回答1:


You are almost right. You indeed need to authorize your app to access domain's Drive. To do this you have to associate the scopes you chose with the service account id that you can find in your API console. This association is made in the administrative panel of your domain, of whoch you posted a screenshot.

I think you got that, but dont forget to use the service account email in your Oauth2 request.

FYI, if you dont specify prn , you access your application's drive, which cant be accessed via the Web UI



来源:https://stackoverflow.com/questions/13528238/google-oauth2-service-accounts-authorization

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