Search code examples
phpoauthgoogle-oauthgoogle-cloud-print

CloudPrint PHP Refresh Token Expires problem


I want to print documents generated in php by cloud print. In general, I did everything, but I have a problem with the expiration of the key. I'm using it: https://github.com/yasirsiddiqui/php-google-cloud-print I generate an access key, everything works, but it expires after about 30 minutes. I want to use this as a cron for printing every few hours so I want to set the key expiration for e.g. 1 year. I found something like this: https://cloud.google.com/apigee/docs/api-platform/antipatterns/oauth-long-expiration but i don't know how to apply it. Thanks for your help in advance.


Solution

  • I found a solution to this problem, if someone would have the same problem you need to do this:

    1. Add 'approval_prompt' => 'force' to $offlineAccessConfig method in Config.php file. In the end it should look like this:
    $offlineAccessConfig = array(
            'access_type' => 'offline',
            'approval_prompt' => 'force'
        );
    
    1. Again hit offlineAccess.php, then you will get a new refresh token. It shouldn't start with "ya29.", but like this: "1//".