Reputation: 25134
I am making a Chrome/Android/iOS app using the cca
toolchain. I am using the chrome.identity
API to get an access_token
to interact with Google APIs.
When I set interactive
to false
(immediate
to true
) the app is able to get the token without showing the permissions dialog again, but it still shows the account chooser every time on my Android device. This ruins the app experience because every time it is opened the user gets an annoying dialog. How can I make the app remember the chosen account after the first time, like it does with the permissions?
Upvotes: 1
Views: 170
Reputation: 138
On Android, you can specify accountHint
in the details
argument of calls to getAuthToken
. For example:
var details = { interactive: true, accountHint: '[email protected]' };
var callback = function(token, account) { ... };
chrome.identity.getAuthToken(details, callback);
This will bypass the account chooser dialog. Note that the callback has account
, which can be stored for this purpose.
Unfortunately, this is Android-only; Chrome on desktop doesn't like it when you add extra stuff to details
. You'll need to use chrome.runtime.getPlatformInfo
to determine what platform you're running on, so that you can create and pass the right details
object. On Android, platformInfo.os
will be cordova-android
.
Upvotes: 2