Coder Social home page Coder Social logo

Comments (5)

stapelberg avatar stapelberg commented on May 20, 2024

Thanks for the report!

Indeed, when I create a new OAuth Client ID, I also get the same error message.

I found https://developers.google.com/identity/oauth2/web/guides/migration-to-gis#gis-popup-ux, but it doesn’t work for me for some reason I have yet to figure out… The popup dialog appears, but after logging in and granting access, nothing seems to happen: no error in the JavaScript developer tools, no requests arriving at the server.

I’ll take another look tomorrow.

from scan2drive.

TechplexEngineer avatar TechplexEngineer commented on May 20, 2024

I'm not sure of all the javascript features you are using. I started investigating and saw this quickstart which seems to not need any javascript to get a list of files and directories. Not sure if this would insulate the code from the everchanging javascript ecosystem. https://developers.google.com/drive/api/quickstart/go

from scan2drive.

stapelberg avatar stapelberg commented on May 20, 2024

The problem isn’t the Drive API itself, which we already use from Go.

The problem is the “sign in to google” functionality, which we need to get an access token to then access the Drive API from Go. This needs to remain JavaScript.

from scan2drive.

TechplexEngineer avatar TechplexEngineer commented on May 20, 2024

Sorry, maybe I'm missing something here, but it seems the example above would enable a redirect based oauth flow so no javascript is needed. The sample code generates a URL which when loaded in a browser presents the Google login screen. Once a successful login has occurred, the url redirects back to the provided redirect_url.
This may present problems based on the limitations google places on redirect_url, but one can fall back to copying the generated code in the URL into the app.

from scan2drive.

stapelberg avatar stapelberg commented on May 20, 2024

I pushed a branch with how far I got: https://github.com/stapelberg/scan2drive/commits/oauth — feel free to check it out, replace the hard-coded http://localhost:7120 everywhere and give it a shot.

I found https://developers.google.com/identity/oauth2/web/guides/migration-to-gis#gis-popup-ux, but it doesn’t work for me for some reason I have yet to figure out… The popup dialog appears, but after logging in and granting access, nothing seems to happen: no error in the JavaScript developer tools, no requests arriving at the server.

The issue was that I had only configured http://localhost:7120 as “Authorised JavaScript origins” in my Client ID. I also needed to add http://localhost (without port) for the popup to work.

That said, we can’t use the implicit flow (with the popup), because it’s impossible to exchange an oauth2 token on the server side. For that, we need to use the redirect flow.


The “HTML API” (still using JavaScript in the background, just the developer doesn’t have to write JavaScript) only works for authN, not for authZ.

With the old library, authN and authZ were sort of mushed together, which was very convenient for tiny applications like this one.

With the new library, the idea seems to be that authN is the first step, and the app only does authZ where needed (e.g. when it actually wants to save a file), with granular fallback in case the user decides to grant only a subset of scopes. This is a good model for larger apps, but rather complicated for scan2drive, so I’m not sure it’s worth trying to implement that. The only advantage we would get is that the consent dialog would be a little more clear (no checkbox that the user can forget to tick).

from scan2drive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.