I also had to go through this without knowing it from the very beginning, so I am happy to help explain this. Here are the answers, but feel free to ask for clarification. Basically, you need to first run a script that requires manual intervention - this allows you to get an access token from Google, which your batch script can use again and again without human intervention. So you have to jump through some hoops from the start, but once that is done, you are all set. So:
Select "web application." Not intuitively, but it will work.
1b. You will be prompted to set up a “consent screen”. It doesn't matter what you do here - just give the project a name.
1c. For uri redirection, remove the provided value from example.com and enter https://developers.google.com/oauthplayground .
Ignore the JSON and P12 keys; They are designed for other types of applications. After filling in the above information and click "Create Client ID", you will get a page (after a pause) that displays the client ID and client secret. These are the two lines that you will need in the code below.
Below is the same solution that you contacted above (and I relied heavily on it), but I edited it to change a few things, primarily to give more information about what is happening. Once you have added your client ID and client secret in the code below, run it. Then you follow these steps:
- Copy the URL that the script prints and paste it into the browser.
- Sign in to Google if he asks you. Then click "Allow access" on the next page.
- On the next page in the browser, the field to the left of the "Authorization code" will appear. (For example: https://members.orcid.org/sites/default/files/image06.png , but your code will be longer.) Do not click the button below the code, but copy this line, being sure to get it all (which may extend out of sight in the dialog box).
- Go back to the terminal where you ran the script and paste the code you copied.
If all goes well, the script will exchange this code for an access token and save the token to disk. Then your batch script can reuse this token.
Here's the extended code to do it all:
#!/usr/bin/perl
After you get this job and have a token stored on disk, the beginning of your batch script can configure access to the spreadsheet as follows:
use Net::Google::Spreadsheets; use Net::Google::DataAPI::Auth::OAuth2; use Net::OAuth2::AccessToken; use Storable; # Authentication code based on example from gist at # https:
source share