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 AccountInfo { | 8 dictionary AccountInfo { |
9 // A unique identifier for the account. This ID will not change | 9 // A unique identifier for the account. This ID will not change |
10 // for the lifetime of the account. | 10 // for the lifetime of the account. |
11 DOMString id; | 11 DOMString id; |
12 }; | 12 }; |
13 | 13 |
| 14 dictionary ProfileUserInfo { |
| 15 // An email address for the user account signed into the current |
| 16 // profile. Empty if the user is not signed in. |
| 17 DOMString email; |
| 18 |
| 19 // A unique identifier for the account. This ID will not change |
| 20 // for the lifetime of the account. Empty if the user is not |
| 21 // signed in. |
| 22 DOMString id; |
| 23 }; |
| 24 |
14 dictionary TokenDetails { | 25 dictionary TokenDetails { |
15 // Fetching a token may require the user to sign-in to Chrome, or | 26 // Fetching a token may require the user to sign-in to Chrome, or |
16 // approve the application's requested scopes. If the interactive | 27 // approve the application's requested scopes. If the interactive |
17 // flag is <code>true</code>, <code>getAuthToken</code> will | 28 // flag is <code>true</code>, <code>getAuthToken</code> will |
18 // prompt the user as necessary. When the flag is | 29 // prompt the user as necessary. When the flag is |
19 // <code>false</code> or omitted, <code>getAuthToken</code> will | 30 // <code>false</code> or omitted, <code>getAuthToken</code> will |
20 // return failure any time a prompt would be required. | 31 // return failure any time a prompt would be required. |
21 boolean? interactive; | 32 boolean? interactive; |
22 | 33 |
23 // The account ID whose token should be returned. If not | 34 // The account ID whose token should be returned. If not |
(...skipping 23 matching lines...) Expand all Loading... |
47 // If the interactive flag is <code>true</code>, the window will | 58 // If the interactive flag is <code>true</code>, the window will |
48 // be displayed when a page load completes. If the flag is | 59 // be displayed when a page load completes. If the flag is |
49 // <code>false</code> or omitted, <code>launchWebAuthFlow</code> | 60 // <code>false</code> or omitted, <code>launchWebAuthFlow</code> |
50 // will return with an error if the initial navigation does not | 61 // will return with an error if the initial navigation does not |
51 // complete the flow. | 62 // complete the flow. |
52 boolean? interactive; | 63 boolean? interactive; |
53 }; | 64 }; |
54 | 65 |
55 callback GetAuthTokenCallback = void (optional DOMString token); | 66 callback GetAuthTokenCallback = void (optional DOMString token); |
56 callback GetAccountsCallback = void (AccountInfo[] accounts); | 67 callback GetAccountsCallback = void (AccountInfo[] accounts); |
| 68 callback GetProfileUserInfoCallback = void (ProfileUserInfo userInfo); |
57 callback InvalidateAuthTokenCallback = void (); | 69 callback InvalidateAuthTokenCallback = void (); |
58 callback LaunchWebAuthFlowCallback = void (optional DOMString responseUrl); | 70 callback LaunchWebAuthFlowCallback = void (optional DOMString responseUrl); |
59 | 71 |
60 interface Functions { | 72 interface Functions { |
61 // Retrieves a list of AccountInfo objects describing the accounts | 73 // Retrieves a list of AccountInfo objects describing the accounts |
62 // present on the profile.<br> | 74 // present on the profile.<br> |
63 // <code>getAccounts</code> is only supported on dev channel. | 75 // <code>getAccounts</code> is only supported on dev channel. |
64 static void getAccounts(GetAccountsCallback callback); | 76 static void getAccounts(GetAccountsCallback callback); |
65 | 77 |
66 // Gets an OAuth2 access token using the client ID and scopes | 78 // Gets an OAuth2 access token using the client ID and scopes |
(...skipping 11 matching lines...) Expand all Loading... |
78 // or Chrome sign in screens if they are not signed in, with with no | 90 // or Chrome sign in screens if they are not signed in, with with no |
79 // context. In particular, do not use <code>getAuthToken</code> | 91 // context. In particular, do not use <code>getAuthToken</code> |
80 // interactively when your app is first launched. | 92 // interactively when your app is first launched. |
81 // | 93 // |
82 // |details| : Token options. | 94 // |details| : Token options. |
83 // |callback| : Called with an OAuth2 access token as specified by the | 95 // |callback| : Called with an OAuth2 access token as specified by the |
84 // manifest, or undefined if there was an error. | 96 // manifest, or undefined if there was an error. |
85 static void getAuthToken(optional TokenDetails details, | 97 static void getAuthToken(optional TokenDetails details, |
86 GetAuthTokenCallback callback); | 98 GetAuthTokenCallback callback); |
87 | 99 |
| 100 // Retrieves email address and obfuscated gaia id of the user |
| 101 // signed into a profile. |
| 102 // |
| 103 // This API is different from identity.getAccounts in two |
| 104 // ways. The information returned is available offline, and it |
| 105 // only applies to the primary account for the profile. |
| 106 static void getProfileUserInfo(GetProfileUserInfoCallback callback); |
| 107 |
88 // Removes an OAuth2 access token from the Identity API's token cache. | 108 // Removes an OAuth2 access token from the Identity API's token cache. |
89 // | 109 // |
90 // If an access token is discovered to be invalid, it should be | 110 // If an access token is discovered to be invalid, it should be |
91 // passed to removeCachedAuthToken to remove it from the | 111 // passed to removeCachedAuthToken to remove it from the |
92 // cache. The app may then retrieve a fresh token with | 112 // cache. The app may then retrieve a fresh token with |
93 // <code>getAuthToken</code>. | 113 // <code>getAuthToken</code>. |
94 // | 114 // |
95 // |details| : Token information. | 115 // |details| : Token information. |
96 // |callback| : Called when the token has been removed from the cache. | 116 // |callback| : Called when the token has been removed from the cache. |
97 static void removeCachedAuthToken( | 117 static void removeCachedAuthToken( |
(...skipping 27 matching lines...) Expand all Loading... |
125 // | 145 // |
126 // |path| : The path appended to the end of the generated URL. | 146 // |path| : The path appended to the end of the generated URL. |
127 [nocompile] static DOMString getRedirectURL(optional DOMString path); | 147 [nocompile] static DOMString getRedirectURL(optional DOMString path); |
128 }; | 148 }; |
129 | 149 |
130 interface Events { | 150 interface Events { |
131 // Fired when signin state changes for an account on the user's profile. | 151 // Fired when signin state changes for an account on the user's profile. |
132 static void onSignInChanged(AccountInfo account, boolean signedIn); | 152 static void onSignInChanged(AccountInfo account, boolean signedIn); |
133 }; | 153 }; |
134 }; | 154 }; |
OLD | NEW |