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?

有帮助吗?

解决方案 2

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.

其他提示

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.

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.

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