ERROR:oauth2client.client:Failed to retrieve access token: {
"error" : "invalid_grant"
}
Check the iss field to make sure your using client email and not client id. I did that on mine and was getting invalid grant
Eric Haskins
Voodoo.com
sent from my Samsung Galaxy S2
No cause you generate the jwt with the private key and email of the service account. Make sure you haven't crossed any info.
Eric
sent from my Samsung Galaxy S2
Mike,I am familiar with python but only using for NLP most of our stuff is PHP so here is how we got the access token in PHP. Of course we cant use it since we are after AdSense Stats which are tied to a user and wont work with a service account<?php$now = time();$jwt_header = base64_encode(json_encode(array('alg' => 'RS256','typ' => 'JWT')));$jwt_claim = base64_encode(json_encode(array(
'iss' => 'xxxxxxxxxx@developer.gserviceaccount.com',
grant_type=assertion&assertion_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fjwt%2F1.0%2Fbearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.{the part after this '.' is unique to your service account}
I'm sorry you guys are having problems. I'd like to help.Mike - what happens if you add the following line right after the call to "authorize"?print credentials._generate_refresh_request_body()
You should see something like:grant_type=assertion&assertion_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fjwt%2F1.0%2Fbearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.{the part after this '.' is unique to your service account}
On Sun, Apr 1, 2012 at 4:39 PM, Eric Haskins <eha...@gmail.com> wrote:
Mike,I am familiar with python but only using for NLP most of our stuff is PHP so here is how we got the access token in PHP. Of course we cant use it since we are after AdSense Stats which are tied to a user and wont work with a service account<?php$now = time();$jwt_header = base64_encode(json_encode(array('alg' => 'RS256','typ' => 'JWT')));$jwt_claim = base64_encode(json_encode(array(
'iss' => 'xxxxxxxxxx@developer.gserviceaccount.com',
Bummer. My info is definitely not crossed - its surely the service account info.
FWIW, what I'm really trying to do is create a C#/.NET based dailyish job that will go our to the GAN (Google Affiliate Network) Events API and get my publisher "events". This really should be a simple thing, but I'm finding it certainly ain't. All the .NET client samples are using "Installed app" approach, which maybe I can live with - but the damn sample code is next to nightmarish. I figured I'd give Service Account a try and with Python - cuz the the python client api looks clean, and I can integrated Python into my .NET app.
storage = Storage('cmd-line.dat') |
credentials = storage.get() http = httplib2.Http() credentials.authorize(http) |