I'm trying to open a file that needs an authorization token for the request, using the cloudstorage api.

Using a token previously defined: 'access_token', my code looks like this:

gcs_file = gcs.open(file_path, 'w', options={'Authorization': access_token})

The problem is that I'm getting the following error:

option Authorization is not supported

I guess that I'm not opening this file properly.

Does someone know how should I invoke this function with the token?

Thanks a lot!

有帮助吗?

解决方案

You can access buckets and objects that don't belong to your project, so long as your app's service account has been granted access. If you have literally been handed a valid OAuth 2 access token and want to use that, you could use the Google API Python Client, which can use the oauth2client.client.AccessTokenCredentials class to authenticate with an access token.

I'm curious, though. Where did your app get ahold of an access token and why do you want to use it?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top