- The application references its API key, which authenticates the application with Google services.
- If the application needs access to the user's personal information, it opens a session with a Google auth server. The auth server opens a dialog box which prompts the user to authorize the use of personal information.
- The application loads the API for the Google service.
- The application initializes a request object (also called a service object) that specifies the data to be returned by the API.
- The application executes the request and processes the data returned by the API.
For a discussion of this code, see the Authentication page.
Get a Google Account
First, sign up for a Google Account if you do not already have one.
Choose Google services
Get access keys for your application
Google defines two levels of API access:
|Simple||API calls do not access any private user data||API key|
|Authorized||API calls can read and write private user data, or the application's own data||OAuth 2.0 credential|
To apply for API access at the Google Developers Console:
- Visit the Google Developers Console. Log in if prompted to do so.
- Create a project for your application (if you have not already done so) by clicking Create project.
- Select Services from the menu. The list of accessible Google services appears.
- Scroll through the list. For each service you want your
application to work with, click the Status switch next to
the service name (so that it switches from OFF
For some services, the Console will display a Terms of Service pane. To go ahead, check the I agree to these terms box, then click Accept.
- Scroll back to the top of the page and click API Access in
The API Access pane appears.
- What you do next depends on what level of access your application
- For simple API access, note the API key (a long string) in the Simple API Access box. That's all you need.
- For authorized access, go on to the next steps.
- Click Create an OAuth 2.0 client ID.
The Create Client ID dialog appears.
- Click the Web application radio button. Type your site or hostname in the field below.
- Click more options under the radio
and domain for your site.
Make sure to enter the domain only, do not include any path value.
If your site supports both HTTP and HTTPS, you can enter multiple values, one per line.
Example: if your application supports both HTTP and HTTPS, and your host is
www.example.com, you should enter the following values:
- Click the Create client ID button to complete the
The Create client ID dialog disappears. The Authorized API Access section now displays your application's OAuth 2.0 credentials.
For information about how to use the OAuth 2.0 Client credential in your application, see the Authentication page.
Where to go from here
- Development Topics: Sub-pages under "Development topics" go into detail about authentication and using CORS, promises, and batch.
- Samples provides code snippets that demonstrate how various features and operations can be implemented.