Skip to content

Commit

Permalink
Update broken links.
Browse files Browse the repository at this point in the history
  • Loading branch information
eesheesh committed Jan 9, 2020
1 parent 5c310e0 commit ed22e19
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/samples.md
@@ -1,6 +1,6 @@
# Samples

This page provides three detailed examples which demonstrate the library's functionality. Browse the [project source](https://code.google.com/p/google-api-javascript-client/source/browse/#hg%2Fsamples) for additional samples.
This page provides three detailed examples which demonstrate the library's functionality. Browse the [project source](https://github.com/google/google-api-javascript-client/tree/master/samples) for additional samples.

Loading an API and Making a Request
-----------------------------------
Expand Down Expand Up @@ -46,11 +46,11 @@ This snippet shows how to load an API and make a request. In this case, the requ

The following sample demonstrates how to get "authorized" access to a Google API using OAuth 2.0. See the full sample at [authSample.html](https://github.com/google/google-api-javascript-client/blob/master/samples/authSample.html).

It's called "authorized" access because the user must give the application direct authorization to use personal data. Simple web-based applications using JavaScript usually get this authorization the way this example does: by displaying button for the user to click. This action triggers a call to a Google auth server, which pops up a standard authorization dialog. For details, see the [Authentication page](/api-client-library/javascript/features/authentication).
It's called "authorized" access because the user must give the application direct authorization to use personal data. Simple web-based applications using JavaScript usually get this authorization the way this example does: by displaying button for the user to click. This action triggers a call to a Google auth server, which pops up a standard authorization dialog. For details, see the [Authentication page](auth.md).

**Note:** Here we use `gapi.load('client:auth2', ...)` to load both the `client` module (for dealing with API requests) and the `auth2` module (for dealing with OAuth 2.0) upfront. The `gapi.client.init` fuction lazily loads `auth2` if it is needed. If you are sure your app needs auth, loading the two modules `'client:auth2'` together before you call `gapi.client.init` will save one script load request.

To make `gapi.client.init` set up OAuth correctly, you would have to assign the `clientID` variable the client ID generated when you registered your application (again, for instructions see the [Getting Started](/api-client-library/javascript/start/start-js#Getaccesskeysforyourapplication) page). The other parameter is `scope`, which in this case is just the scope for user profile permission.
To make `gapi.client.init` set up OAuth correctly, you would have to assign the `clientID` variable the client ID generated when you registered your application (for instructions see [Integrating Google Sign-In into your web app](https://developers.google.com/identity/sign-in/web/sign-in)). The other parameter is `scope`, which in this case is just the scope for user profile permission.

When the user clicks **Authorize**, the `gapi.auth2.getAuthInstance().signIn()` function is called, which shows user a popup window to let user authorize. Note that the `gapi.auth2.getAuthInstance().signIn()` can be only called from a user interaction context for most browsers (i.e. do not call it when your app starts, but call it in a button click handler).

Expand Down Expand Up @@ -88,4 +88,4 @@ The following code snippet shows how to load the library without blocking UI loa

## Putting it all together

The file [authSample.html](https://github.com/google/google-api-javascript-client/blob/master/samples/authSample.html) expands on the concepts on this page and provides a more complete example of making an authenticated call to the Google People API.
The file [authSample.html](https://github.com/google/google-api-javascript-client/blob/master/samples/authSample.html) expands on the concepts on this page and provides a more complete example of making an authenticated call to the Google People API.

0 comments on commit ed22e19

Please sign in to comment.