Open czzarr opened 7 years ago
HI @czzarr,
This is a great idea and we're going to find the time to update these examples.
There is an available Migration Guide, but I think it doesn't emphasize enough the fundamental difference in GSI v1 and GSI v2.
gapi.auth2.init
/signIn
does a lot for you in the background, like automatically signing in users when initializing, automatically refreshing access token, syncing user state between tabs, and it handles the full sign-in flow without need to parse URLs or pass state as done in the drive-music-player example.
For instance, looking at this file of the first sample app you sent, most of the code implements features now entirely handled in GSI v2.
This should be clearer when we offer an example of migration.
I would second the need for a real example using gapi.auth2
. In particular, it is not clear to me that it works at all with the Realtime API (I have tried to migrate a realtime application to gapi.auth2
, and the realtime client does not seem to pick up the token). Since the documentation for the older gapi.auth
interface seems to be no longer available (so far as I can tell), it makes targeting either of these APIs challenging.
Hi @ian-r-rose, I will have an example very soon. Regarding your problem, it seems that this is a bug with the Realtime API. I will contact the relevant team.
Great, thanks @TMSCH !
Hi @TMSCH, any updates to this?
Hi @ian-r-rose, I have tried with my pull request, and it is now working :) let me know if that works for you!
Thanks, @TMSCH, I will check it out.
Hi @TMSCH, I have tried your PR (googledrive/drive-music-player#195) with the Drive Music Player and I am still seeing the same issue with the realtime library. That is to say, it does not seem to be picking up the token from gapi.auth2
, and I am getting the error
Drive Realtime API Error: token_refresh_required: The OAuth token must be refreshed.
The workaround of manually setting the token using gapi.auth
that is used in DMP master still seems to work.
@ian-r-rose ah, interesting. When I tried the other day it worked. The Realtime API library has a design that doesn't fit well with gapi.auth/gapi.auth2/gapi.client design. I've been talking with the maintainer to find a suitable solution.
Is found no way to use the gapi.client.init / gapi.client.drive api together with gapi.drive.realtime. It seems gapi.client.init does auth2 and gapi.realtime does auth.
How am I supposed to use gapi.realtime for a drive kind of "docs" application ?
I found no workarround in all the docs. All realtime samples where "gapi.auth", all drive samples were "gapi.client.init" and using both did not work.
@ developers of this library
I would suggest reimplementing authorization & authentication in google-drive example apps such as https://github.com/googledrive/drive-music-player https://github.com/googledrive/realtime-playground, https://github.com/googledrive/zipextractor or https://github.com/googledrive/web-quickeditor
This way you will see how hard it is to migrate from
gapi.auth
togapi.auth2
, see where holes are both in functionality and documentation, provide examples a bit more complete than the obvious 101 examples that appear on the documentation, and also be able to provide a thorough upgrading guide.Right now I haven't found a serious example using
gapi.auth2
. If it exists and I simply didn't find it, please point me to it.