![]() Now for testing purposes you should leave this next variable as an empty string. // Location to store access token (needs be writeable ).// Location of private key on your server (JSON downloadable from Google ).Location to store access token (needs be writeable) Let's specify the output page to be in JSON format:Ĭopy raw styler // Location of private key on your server (JSON downloadable from Google) I can also unset multiple branches of variables with fewer commands than unsetting specific variables. I can also output any of the variables and responses for debugging purposes. Simply because we'll be working with JSON data and this encodes/decodes easily into PHP arrays. I'm going to go through each section of the code to go through the logic and highlight any changes you may need to make. You can do it in pure PHP and all you need is the JSON key that you generated in your Google console. Do not waste your time like I did on the public key, verifying a JWT signature, or including any third-party libraries. It is taken from Google's documentation as well as other forums and websites that try to explain it. This took me the best part of a month to get working. Again this script doesn't need the client libraries, composer, vendor, etc. In that this one doesn't prompt for a user. This is very different to my code for OAuth when attended: Google Authentication - OAuth 2.0 using PHP/cURL. This is an article explaining the code needed to write a PHP script which generates an access token for a service account which in turn is used to list files in a team's Google Drive.
0 Comments
Leave a Reply. |