Dominic Preuss
Dominic Preuss

Reputation: 697

SignedJwtAssertionCredentials doesn't work

I am thoroughly stuck using the Google API Python Client. I am trying to do a very simple thing. I have added an app in the Google Apps Marketplace and have authorized a user to get access to my domain.

Now, I want to provision users. I am trying to get access to the Admin SDK without an enduser.

I am using the official Sample code as the template - https://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py

I am getting the following error: Error at /test-oauth/ [('asn1 encoding routines', 'ASN1_D2I_READ_BIO', 'not enough data')]

It is occuring in the Google oauth2 client code - /oauth2client/crypt.py in from_string, line 131

I am using Python 2.7, Django 1.5.2 and Google Python API Client 1.2 (and I added pyOpenSSL and pyCrypto). Here is what I have installed:

distribute (0.6.36)

lxml (3.2.3)

MySQL-python (1.2.4)

numpy (1.7.1)

pip (1.4)

pycrypto (2.6)

pyOpenSSL (0.11)

scikit-learn (0.14.1)

setuptools (0.9.8)

wsgiref (0.1.2)

Here is the code:

def get_google_api_data(request):

# The 2-LO authorization section
credentials = SignedJwtAssertionCredentials(settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY,
                                            settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET,
                   scope='https://www.googleapis.com/auth/admin.directory.user.readonly')
http = httplib2.Http()
http = credentials.authorize(http)

# Initializing the Tasks API service
service = build('admin', 'directory_v1', http=http)

return

Can anyone tell my why I can't connect to the service?

Dominic

Upvotes: 0

Views: 557

Answers (1)

AMS
AMS

Reputation: 253

For starters: 2 legged OAuth != OAuth2
This is not how you are supposed to use the Admin SDK API. Please read this to learn about OAuth2.

2 Legged OAuth auth is deprecated

Upvotes: 1

Related Questions