androidgoogle-cloud-print

XSRF Token Validation Failed Google Cloud Print


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?


Solution

  • 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.