1

I have Refresh Token, OAuth Client ID, and OAuth Client Secret but I do not know how to get the Access Token in PHP. I am stuck with an Access Token that expires every 1 Hour.

Note: I want this process to be automatic without any intervention from the user. (No resurrection or login).

  • Do you mean OAuth::getAccessToken ? If so, did you check the [official documentation](https://www.php.net/manual/en/oauth.getaccesstoken.php) ? – Ken Lee Oct 12 '22 at 01:12
  • No. I mean OAuth 2.0 Playground. Google API one. – Abdelmalek ELBOUDARY Oct 12 '22 at 01:17
  • If I understand what you want correctly , please use Admin API . This [link](https://cloud.google.com/appengine/docs/admin-api/accessing-the-api) has the details to uses a client ID that was created in the Google Cloud console to request an `access token` and then redirect the user to an authorized URI where your app receives the token. (But in the first place, enable the admin api) – Ken Lee Oct 12 '22 at 01:19
  • Thank you for taking the time and responding to my question. Unfortunately, this is not quite what I'm looking for. I'm using a PHP script to connect to my Blogger using OAuth 2.0 Access Token; however, this Access Token expires after 1 hour and I have to "refresh" it manually. After I searched for a bit, I found that there is something called Refresh Token and it could be used to get a new Access Token. The issue is that I don't know how I can use the Refresh Token to get a new Access Token in PHP. – Abdelmalek ELBOUDARY Oct 12 '22 at 01:41
  • The closest answer I found that could solve my issue is this one https://stackoverflow.com/questions/19766912/how-do-i-authorise-an-app-web-or-installed-without-user-intervention (To pinpoint the potential solution, please refer to the function that is called "get_access_token_using_saved_refresh_token()"). YET, the proposed solution is in JavaScript and I want it in PHP. – Abdelmalek ELBOUDARY Oct 12 '22 at 01:46
  • I see. Please try converting the JS to PHP : check this post: [Mimicking an ajax call with Curl PHP](https://stackoverflow.com/questions/19212293/mimicking-an-ajax-call-with-curl-php) – Ken Lee Oct 12 '22 at 01:53

0 Answers0