File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6363 ************************************************/
6464if (isset ($ _SESSION ['service_token ' ])) {
6565 $ client ->setAccessToken ($ _SESSION ['service_token ' ]);
66- } else {
67- $ key = file_get_contents ($ key_file_location );
68- $ cred = new Google_Auth_AssertionCredentials (
69- $ service_account_name ,
70- array ('https://www.googleapis.com/auth/books ' ),
71- $ key
72- );
73- // If we were retrieving on behalf of a specific delegated
74- // user we should set the subject here.
75- // $cred->sub = "emailaddress@yourdomain.com";
76- $ client ->setAssertionCredentials ($ cred );
77- $ _SESSION ['service_token ' ] = $ client ->getAccessToken ();
7866}
67+ $ key = file_get_contents ($ key_file_location );
68+ $ cred = new Google_Auth_AssertionCredentials (
69+ $ service_account_name ,
70+ array ('https://www.googleapis.com/auth/books ' ),
71+ $ key
72+ );
73+ $ client ->setAssertionCredentials ($ cred );
74+ if ($ client ->getAuth ()->isAccessTokenExpired ()) {
75+ $ client ->getAuth ()->refreshTokenWithAssertion ($ cred );
76+ }
77+ $ _SESSION ['service_token ' ] = $ client ->getAccessToken ();
7978
8079/************************************************
8180 We're just going to make the same call as in the
You can’t perform that action at this time.
0 commit comments