5

How to obtain XSRF Token in Google Cloud Print?

When I tried to submit job print. It's always get message "XSRF Token Validation Failed.".

I've checked in "Inspect Elements" in http://www.google.com/cloudprint/simulate.html. And there's a hidden text input with name 'xsrf'.

How to obtain XSRF Token?

Crazyshezy
  • 1,530
  • 6
  • 27
  • 45
Dhinx
  • 105
  • 1
  • 7

3 Answers3

2

I had problems with this too, and came here because I couldn't find the answer in Google's API documentation. If someone else needs an XSRF token for Google Cloud Print, this is wat worked for me.

First you have to get an OAuth2 access token from Google with the following scope enabled:

https://www.googleapis.com/auth/cloudprint

After that, you can make a call to www.google.com/cloudprint/xsrf with Authorization: Bearer YOUR_ACCESS_TOKEN in the header.

With cURL that would look like this:

curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" www.google.com/cloudprint/xsrf

Good luck.

piscator
  • 8,028
  • 5
  • 23
  • 32
1

I faced this problem and got following response.

{
 "success": false,
 "message": "XSRF token validation failed.",
 "request": {
 "time": "0",
 "users": [
 "abc@gmail.com"
 ],
 "params": {
 },
 "user": "abc@gmail.com"
 },
"errorCode": 9
}

Searched on google but nothing found except your post here. Finally spending 1 hour fixed by setting mimeType(application/pdf) as following

Intent printIntent = new Intent(MyActivity.this,
            PrintDialogActivity.class);
printIntent.setDataAndType(Uri.fromFile(file),
            "application/pdf");

Hope this will help others.

Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45
  • Where do I put that? I am following this: https://support.google.com/a/answer/2906017?hl=en – apple16 Aug 22 '14 at 21:02
  • Found that it was just because I had typed my password incorrectly. BTW, if you want to generate a new XSRF token, the script on that link generates one and puts it in the conf file – apple16 Aug 22 '14 at 21:49
0

I also got same error while creating my first plan. You have to give full control to the admin and/or user accessing C:\Program Files\Bamboo folder. Then start Bamboo server.

It worked for me.

Amit
  • 1