We have the following scenario:
- User logs into Google Drive with Account A
- Then, user adds a new account and logs into Google Drive with Account B (two active valid accounts at this point)
- While in Account B, the user clicks the Create button in Drive. Our app requests the user to select which account he wants to use for the file creation and the user selects Account B (same one he was already using). Our app shows the file picker but the files he gets to see are the ones in the Account A, not in Account B.
We have followed all the steps indicated in the developers API guide, including setting the authorization token. Here is our createPicker function:
function createPicker() {
if (pickerApiLoaded && oauthToken) {
new google.picker.PickerBuilder()
.addView(google.picker.ViewId.DOCS)
.setSelectableMimeTypes(selectableMimes)
**.setOAuthToken(oauthToken)**
.setCallback(pickerCallback)
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.build()
.setVisible(true);
}
}
and this is how we are obtaining the oauthToken value:
gapi.auth.authorize({
client_id: clientId,
scope: scope,
immediate: false,
}, function(authResult) {
if (authResult && !authResult.error) {
**oauthToken = gapi.auth.getToken().access_token;**
createPicker();
}
});
While debugging, we have confirmed that, if the user selects Account A, we get one oAuthToken, and if the user selects Account B, we get a different one. So we are sending different tokens for each account, as it is supposed to be.
Any idea on why the user, after selecting Account B (which generates a token for Account B) gets to see the files on Account A? Any idea of what are we missing or doing wrong?