youtube-apiyoutube-channels

javascript youtube api request cache


i am having a strange problem.

I use OAuth2 and gapi.auth.authorize({client_id:'...',scope:'../youtube',immediate:false}) to log a user into my app. This method lets the user choose which of his connected accounts(identities) to use.

I retrieve user's video using gapi.client.youtube.channels.list and gapi.client.youtube.playlistItems.list.

later in the same app the user can click a button to choose another of his connected accounts(identities). i use again gapi.auth.authorize({client_id:'...',scope:'../youtube',immediate:false}) method.

the problem is that after successfull change of the account the gapi.client.youtube.channels.list method returns the cached result from the first call.

some remarks: -in ie 11 it works fine - in google chrome, if i disable the cache from developers tools it also works fine - before the call to channels.list i call /oauth2/v2/tokeninfo and /plus/v1/people/me and they both return correct results, that is the second account's data

is there any way to correct this? thank you.


Solution

  • Someone can overcome this by using XMLHttpRequest( see https://developers.google.com/api-client-library/javascript/features/cors) . It's probably a bug of javascript YouTube api.