OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.identity</code> API to get OAuth2 access tokens. | 5 // Use the <code>chrome.identity</code> API to get OAuth2 access tokens. |
6 namespace identity { | 6 namespace identity { |
7 | 7 |
8 dictionary TokenDetails { | 8 dictionary TokenDetails { |
9 // Fetching a token may require the user to sign-in to Chrome, or | 9 // Fetching a token may require the user to sign-in to Chrome, or |
10 // approve the application's requested scopes. If the interactive | 10 // approve the application's requested scopes. If the interactive |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // present on the profile.<br> | 55 // present on the profile.<br> |
56 // <code>getAccounts</code> is only supported on dev channel. | 56 // <code>getAccounts</code> is only supported on dev channel. |
57 static void getAccounts(GetAccountsCallback callback); | 57 static void getAccounts(GetAccountsCallback callback); |
58 | 58 |
59 // Gets an OAuth2 access token using the client ID and scopes | 59 // Gets an OAuth2 access token using the client ID and scopes |
60 // specified in the <a | 60 // specified in the <a |
61 // href="app_identity.html#update_manifest"><code>oauth2</code> | 61 // href="app_identity.html#update_manifest"><code>oauth2</code> |
62 // section of manifest.json</a>. | 62 // section of manifest.json</a>. |
63 // | 63 // |
64 // The Identity API caches access tokens in memory, so it's ok to | 64 // The Identity API caches access tokens in memory, so it's ok to |
65 // call <code>getAuthToken</code> any time a token is | 65 // call <code>getAuthToken</code> non-interactively any time a token is |
66 // required. The token cache automatically handles expiration. | 66 // required. The token cache automatically handles expiration. |
67 // | 67 // |
| 68 // For a good user experience it is important interactive token requests are |
| 69 // initiated by UI in your app explaining what the authorization is for. |
| 70 // Failing to do this will cause your users to get authorization requests, |
| 71 // or Chrome sign in screens if they are not signed in, with with no |
| 72 // context. In particular, do not use <code>getAuthToken</code> |
| 73 // interactively when your app is first launched. |
| 74 // |
68 // |details| : Token options. | 75 // |details| : Token options. |
69 // |callback| : Called with an OAuth2 access token as specified by the | 76 // |callback| : Called with an OAuth2 access token as specified by the |
70 // manifest, or undefined if there was an error. | 77 // manifest, or undefined if there was an error. |
71 static void getAuthToken(optional TokenDetails details, | 78 static void getAuthToken(optional TokenDetails details, |
72 GetAuthTokenCallback callback); | 79 GetAuthTokenCallback callback); |
73 | 80 |
74 // Removes an OAuth2 access token from the Identity API's token cache. | 81 // Removes an OAuth2 access token from the Identity API's token cache. |
75 // | 82 // |
76 // If an access token is discovered to be invalid, it should be | 83 // If an access token is discovered to be invalid, it should be |
77 // passed to removeCachedAuthToken to remove it from the | 84 // passed to removeCachedAuthToken to remove it from the |
(...skipping 11 matching lines...) Expand all Loading... |
89 // providers by launching a web view and navigating it to the | 96 // providers by launching a web view and navigating it to the |
90 // first URL in the provider's auth flow. When the provider | 97 // first URL in the provider's auth flow. When the provider |
91 // redirects to a URL matching the pattern | 98 // redirects to a URL matching the pattern |
92 // <code>https://<app-id>.chromiumapp.org/*</code>, the | 99 // <code>https://<app-id>.chromiumapp.org/*</code>, the |
93 // window will close, and the final redirect URL will be passed to | 100 // window will close, and the final redirect URL will be passed to |
94 // the <var>callback</var> function. | 101 // the <var>callback</var> function. |
95 // | 102 // |
96 // For a good user experience it is important interactive auth flows are | 103 // For a good user experience it is important interactive auth flows are |
97 // initiated by UI in your app explaining what the authorization is for. | 104 // initiated by UI in your app explaining what the authorization is for. |
98 // Failing to do this will cause your users to get authorization requests | 105 // Failing to do this will cause your users to get authorization requests |
99 // - or even Chrome sign in screens if they are not signed in - with | 106 // with no context. In particular, do not launch an interactive auth flow |
100 // no context. In particular, do not launch an interactive auth flow when | 107 // when your app is first launched. |
101 // your app is first launched. | |
102 // | 108 // |
103 // |details| : WebAuth flow options. | 109 // |details| : WebAuth flow options. |
104 // |callback| : Called with the URL redirected back to your application. | 110 // |callback| : Called with the URL redirected back to your application. |
105 static void launchWebAuthFlow(WebAuthFlowDetails details, | 111 static void launchWebAuthFlow(WebAuthFlowDetails details, |
106 LaunchWebAuthFlowCallback callback); | 112 LaunchWebAuthFlowCallback callback); |
107 | 113 |
108 // Generates a redirect URL to be used in |launchWebAuthFlow|. | 114 // Generates a redirect URL to be used in |launchWebAuthFlow|. |
109 // | 115 // |
110 // The generated URLs match the pattern | 116 // The generated URLs match the pattern |
111 // <code>https://<app-id>.chromiumapp.org/*</code>. | 117 // <code>https://<app-id>.chromiumapp.org/*</code>. |
112 // | 118 // |
113 // |path| : The path appended to the end of the generated URL. | 119 // |path| : The path appended to the end of the generated URL. |
114 [nocompile] static DOMString getRedirectURL(optional DOMString path); | 120 [nocompile] static DOMString getRedirectURL(optional DOMString path); |
115 }; | 121 }; |
116 | 122 |
117 interface Events { | 123 interface Events { |
118 // Fired when signin state changes for an account on the user's profile. | 124 // Fired when signin state changes for an account on the user's profile. |
119 static void onSignInChanged(AccountInfo account, boolean signedIn); | 125 static void onSignInChanged(AccountInfo account, boolean signedIn); |
120 }; | 126 }; |
121 }; | 127 }; |
OLD | NEW |