OAuth 2.0 for Server to Server Applications using Python 3.4, cannot import name 'SERVICE_ACCOUNT'

685 views
Skip to first unread message

Dmitry Bogomolov

unread,
Feb 29, 2016, 11:43:51 AM2/29/16
to Google API Python Client

Hi!

I'm trying to implement 'Server to Server' OAuth authentication in my Python 3.4 application to work with Google Cloud Storage. So, in general it is described on this page Using OAuth 2.0 for Server to Server Applications

But there's an error while I'm running my script:

Traceback (most recent call last):
File "my_script.py", line 4, in from oauth2client.service_account import ServiceAccountCredentials
File "/usr/local/lib/python3.4/dist-packages/oauth2client/service_account.py", line 31, in from oauth2client.client import SERVICE_ACCOUNT

ImportError: cannot import name 'SERVICE_ACCOUNT'

So, here's my code:

from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http

scopes = ['https://www.googleapis.com/auth/cloud-platform.read-only']

credentials = ServiceAccountCredentials.from_json_keyfile_name('./keyfile.json', scopes)

http_auth = credentials.authorize(Http())
service = build('storage', 'v1', http=http_auth)


If you would be so kind to help me with it, it would be great! It's the one of my first scripts on a Python language, and I'm a newbie both in Python and in Linux worlds, so I can miss something very obvious.

If it is important, my OS is Ubuntu 12.04.

Thanks!

Nathaniel Manista

unread,
Feb 29, 2016, 7:17:28 PM2/29/16
to google-api-p...@googlegroups.com
Do you happen to know what versions of each of oauth2client and google-api-python-client you have, and how you installed them?
-N
Reply all
Reply to author
Forward
0 new messages