Giter Club home page Giter Club logo

Comments (7)

thegengen avatar thegengen commented on July 22, 2024

Hi, and thanks for reporting. Could you share a snippet of the code you're using (or at least the code you're using to debug the issue?)

Thanks.

from cloudprint.

telmogh avatar telmogh commented on July 22, 2024

Hi there,

I have this

client = CloudPrint::Client.new(client_id: Settings.google.cloudprint.key, client_secret: Settings.google.cloudprint.secret)
redirect_url = Settings.urls.root + "/cloudprint/callback"
token = client.auth.generate_token(params[:code], redirect_url)

When running the last line is when I get the error.

from cloudprint.

thegengen avatar thegengen commented on July 22, 2024

OK, so I take it that the third line is in a separate controller under the callback action for CloudPrint. Have you confirmed that params[:code] is not nil when you try to generate the token?

Also, I'm not sure what you mean by 'we try to hit the endpoint on Google again.' Generating the refresh token can only be done once -- after the very first time users sign in, when they are redirected back to your application. You have to save the token there and then and reuse it from that point on.

from cloudprint.

telmogh avatar telmogh commented on July 22, 2024

The params[:code] is not nil, I've checked.

So, a User in my application can have multiple Organization, for each Organization I need to allow access to Google Cloud Print, but since they already gave access for, lets say, the first Organization, it doesn't work for the second one.

from cloudprint.

thegengen avatar thegengen commented on July 22, 2024

OK, so are you trying to generate more than one refresh token from the same code? Because that won't work. If that's what you're trying, you should share the refresh token between multiple orgs instead.

If not, I'm afraid I'll need to see a minimal example that I can run on my end to reproduce this bug.

from cloudprint.

telmogh avatar telmogh commented on July 22, 2024

Ok, I'll change the code on my end and try a different approach, thanks 👍

from cloudprint.

troelskn avatar troelskn commented on July 22, 2024

For future reference, since I spent some time figuring this out: If you try to re-auth, it will fail, because you already have received a valid authentication previously. To work around this, append &prompt=consent to the auth_url. E.g.:

client.auth.generate_url(redirect_url) + "&prompt=consent"

We might want to make this default behaviour and/or document it in the readme.

from cloudprint.

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.