Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 5.92 KB

Creating-client_secrets.json-and-oauth2service.json.md

File metadata and controls

64 lines (40 loc) · 5.92 KB

Table of Contents generated with DocToc

Creating Your Own OAuth Console clients_secrets.json

In the past, all GAM installations shared the same client_secrets.json file included with the GAM download. This file identifies the GAM project to Google but it does not provide any special access rights to your Google Apps domain (that's what the oauth2.txt file is for).

With GAM versions 3.02 and higher, you need to create your own client_secrets.json file. This gives you your own personal quota of API requests to be used.

Steps

  1. You can access the API Console at https://cloud.google.com/console you'll need to be logged in to your Google Account. The account does not need to be in your Google Apps domain or have any special rights.

  2. Click the big red "Create Project" button to get started.

  3. Give your project a name and id as you prefer.

  4. You may be prompted to verify via SMS. Complete SMS verification before continuing.

  5. Click the "API & auth" link to the left.

  6. Enable the Admin SDK by clicking the OFF button so that it turns to on. If you're prompted with terms of service, accept them.

  7. Also enable Calendar API, Drive API, Drive SDK, Enterprise License Manager API and Group Settings API accepting terms of service whenever prompted. The services that were on by default (BigQuery API, etc) can be left alone or turned off, GAM does not use them.

  8. Click "Consent screen to the left, enter a PRODUCT NAME and SAVE your changes.

  9. Click "Credentials to the left.

  10. Click the "CREATE NEW CLIENT ID" red button.

  11. Choose "Installed Application" for Application Type.

  12. Choose "Other" for Installed Application Type.

  13. Under "Client ID for Native Application", click the red "Download JSON" button. Make sure you are clicking the download button under "Client ID for Native Application"!

  14. Name your file "client_secrets.json" and put it in the exact same path as gam.py or gam.exe.

  15. You can confirm which Project your GAM authorization is using by running:

    gam oauth info

    380063494358.apps.googleusercontent.com is the Client ID for the client_secrets.json that came with old versions of the GAM download. If you see it, you're not using your own project, run "gam oauth revoke" to delete the existing oauth2.txt authorization and then "gam info domain" to redo the authorization with your own project.

Creating Your Own OAuth2service.json

  1. Starting from the end of the previous step after creating your client_secrets.json file, Below the section for the Installed applications, click on Create another client ID…

  2. On the next screen select Application type: Service account

  3. Click Create Client ID

  4. Click Download private key then save this file as oauth2service.p12 and save it in the same folder as your GAM installation, same place that you saved your client_secrets.json file then close the dialog window.

  5. Navigate to the section of the page for the Service Account, and then click on Download JSON, save the file to the same folder as your GAM installation and rename it to oauth2service.json

  6. In the section for the Service Account, copy your Client ID to the clipboard

  7. In a new browser window, go to the Google Apps Admin dashboard (admin.google.com) and navigate to the Security Icon, click Show More then Advanced settings, and under the Authentication section click on Manage API client access.

  8. Click in the Client Name field at the top left and paste in the OAuth2 Client ID that you copied to the clipboard previously

  9. Next paste the following text into the One or More API Scopes field and click Authorize: https://www.googleapis.com/auth/calendar,https://www.googleapis.com/auth/drive

  10. You should now be setup with your OAuth2service.json and be able to access the Drive and Calendar Commands.