| OLD | NEW |
| 1 <h1>User Authentication</h1> | 1 <h1>User Authentication</h1> |
| 2 | 2 |
| 3 <p> | 3 <p> |
| 4 Web authentication protocols utilize HTTP features, | 4 Web authentication protocols utilize HTTP features, |
| 5 but Chrome Apps run inside the app container; | 5 but Chrome Apps run inside the app container; |
| 6 they don’t load over HTTP and can’t perform redirects or set cookies. | 6 they don’t load over HTTP and can’t perform redirects or set cookies. |
| 7 </p> | 7 </p> |
| 8 | 8 |
| 9 <p> | 9 <p> |
| 10 Use the <a href="identity">Chrome Identity API</a> | 10 Use the <a href="identity">Chrome Identity API</a> |
| 11 to authenticate users: | 11 to authenticate users: |
| 12 the <code>getAuthToken</code> for users logged into their Google Account and | 12 the <code>getAuthToken</code> for users logged into their Google Account and |
| 13 the <code>launchWebAuthFlow</code> for users logged into a non-Google account. | 13 the <code>launchWebAuthFlow</code> for users logged into a non-Google account. |
| 14 If your app uses its own server to authenticate users, you will need to use the
latter. | 14 If your app uses its own server to authenticate users, you will need to use the
latter. |
| 15 </p> | 15 </p> |
| 16 | 16 |
| 17 <p class="note"> | 17 <p class="note"> |
| 18 <b>API Samples: </b> | 18 <b>API Samples: </b> |
| 19 Want to play with the code? | 19 Want to play with the code? |
| 20 Check out | 20 Check out |
| 21 <a href="https://github.com/GoogleChrome/chrome-app-samples#_feature_identity">t
hese samples</a>, | 21 <a href="https://github.com/GoogleChrome/chrome-app-samples#_feature_identity">t
hese samples</a>, |
| 22 in particular the | 22 in particular the |
| 23 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/identity
#readme">identity sample</a>. | 23 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/
identity#readme">identity sample</a>. |
| 24 </p> | 24 </p> |
| 25 | 25 |
| 26 <h2 id="how">How it works</h2> | 26 <h2 id="how">How it works</h2> |
| 27 | 27 |
| 28 <p> | 28 <p> |
| 29 Chrome Apps users have a Google account associated with their | 29 Chrome Apps users have a Google account associated with their |
| 30 profile. Apps can get OAuth2 tokens for these users using | 30 profile. Apps can get OAuth2 tokens for these users using |
| 31 the <code>getAuthToken</code> API. | 31 the <code>getAuthToken</code> API. |
| 32 </p> | 32 </p> |
| 33 | 33 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 If the app ID here does not match your app ID, | 125 If the app ID here does not match your app ID, |
| 126 an error will occur when your app calls <a href="#token">getAuthToken()</a>. | 126 an error will occur when your app calls <a href="#token">getAuthToken()</a>. |
| 127 </p> | 127 </p> |
| 128 | 128 |
| 129 <h3 id="update_manifest">Update your manifest with OAuth2 client ID and scopes</
h3> | 129 <h3 id="update_manifest">Update your manifest with OAuth2 client ID and scopes</
h3> |
| 130 | 130 |
| 131 <p> | 131 <p> |
| 132 You need to update your manifest to include | 132 You need to update your manifest to include |
| 133 the client ID and scopes. | 133 the client ID and scopes. |
| 134 Here's the sample "oauth2" for the | 134 Here's the sample "oauth2" for the |
| 135 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/gdrive">
gdrive sample</a>: | 135 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/
gdrive">gdrive sample</a>: |
| 136 </p> | 136 </p> |
| 137 | 137 |
| 138 <pre data-filename="manifest.json"> | 138 <pre data-filename="manifest.json"> |
| 139 "oauth2": { | 139 "oauth2": { |
| 140 "client_id": "665859454684.apps.googleusercontent.com", | 140 "client_id": "665859454684.apps.googleusercontent.com", |
| 141 "scopes": [ | 141 "scopes": [ |
| 142 "https://www.googleapis.com/auth/drive" | 142 "https://www.googleapis.com/auth/drive" |
| 143 ] | 143 ] |
| 144 } | 144 } |
| 145 </pre> | 145 </pre> |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 </p> | 348 </p> |
| 349 | 349 |
| 350 <p> | 350 <p> |
| 351 The best practice we suggest is to use silent mode | 351 The best practice we suggest is to use silent mode |
| 352 when there is no user gesture involved and use interactive mode | 352 when there is no user gesture involved and use interactive mode |
| 353 if there is a user gesture (for example, the user clicked the Sign In button in
your app). | 353 if there is a user gesture (for example, the user clicked the Sign In button in
your app). |
| 354 Note that we do not enforce gesture requirement. | 354 Note that we do not enforce gesture requirement. |
| 355 </p> | 355 </p> |
| 356 | 356 |
| 357 <p class="backtotop"><a href="#top">Back to top</a></p> | 357 <p class="backtotop"><a href="#top">Back to top</a></p> |
| OLD | NEW |