Complete the steps described in the rest of this page to create a simple browser application that makes requests to the G Suite Reseller API.
Prerequisites
To run this quickstart, you need the following prerequisites:
- Python 2.4 or greater (to provide a web server)
- A Google Reseller domain instance
- A fully executed G Suite partner agreement
Step 1: Turn on the G Suite Reseller API
Click this button to create a new Cloud Platform project and automatically enable the G Suite Reseller API:
Enable the G Suite Reseller API
Take note of the Client ID shown in the resulting dialog. Then click the following button to create an API key in the same project:Take note of the API Key shown in the resulting dialog.
Step 2: Set up the sample
Create a file named index.html
and copy in the following code:
Replace the placeholder <YOUR_CLIENT_ID>
in the copied code with the client ID
you created in Step 1.
Likewise, replace the placeholder <YOUR_API_KEY>
with the API key you created.
Step 3: Run the sample
- Start the web server using the following command from your working directory:
Python 2.x
python -m SimpleHTTPServer 8000
Python 3.x
python -m http.server 8000
- Load the URL
http://localhost:8000
into your browser.
The first time you run the sample, it prompts you to authorize access:
Click the Authorize button to open the authorization window.
If you're not already logged in to your Google account, the window prompts you to log in. If you are logged in to multiple Google accounts, you must select one account to use for the authorization.
- Click the Accept button.
Notes
- After the initial user authorization, calls to
gapi.auth.authorize
that useimmediate:true
mode obtain an auth token without user interaction.
Further reading
- Google Developers Console help documentation
- Google APIs Client for JavaScript documentation
- G Suite Reseller API codelab
- G Suite Reseller API reference documentation
Troubleshooting
This section describes some common issues that you may encounter while attempting to run this quickstart and suggests possible solutions.
Error: origin_mismatch
This error occurs during the authorization flow if the host and port used to serve the web page doesn't match an allowed JavaScript origin on your Google Developers Console project. Make sure you set an authorized JavaScript origin and that the URL in your browser matches the origin's URL.
idpiframe_initialization_failed: Failed to read the 'localStorage' property from 'Window'
The Google Sign-in library requires that
3rd party cookies and data storage
is enabled in the web browser. For users that run into this error, prompt them
to enable the feature or add an exception for accounts.google.com
.
idpiframe_initialization_failed: Not a valid origin for the client
The Google Sign-in library requires that the domain registered in the Google Developers Console matches the domain being used to host the web page. Ensure that the origin you registered matches the URL in the browser.
This app isn't verified.
The OAuth consent screen that is presented to the user may show the warning "This app isn't verified" if it is requesting scopes that provide access to sensitive user data. These applications must eventually go through the verification process to remove that warning and other limitations. During the development phase you can continue past this warning by clicking Advanced > Go to {Project Name} (unsafe).