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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With