Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring OAuth tokens on a per-connection basis. #177

Open
thejazz15 opened this issue Jan 8, 2019 · 11 comments
Open

Configuring OAuth tokens on a per-connection basis. #177

thejazz15 opened this issue Jan 8, 2019 · 11 comments

Comments

@thejazz15
Copy link

After reading the docs I assume the OAuth tokens are configured globally.

Hubspot.configure(
    client_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    client_secret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    redirect_uri: "https://myapp.com/oauth",
    access_token: access_token)

Is there any possible way to configure them on per-connection basis?

@cbisnett
Copy link
Collaborator

cbisnett commented Jan 8, 2019

Not yet. I've got an idea for how I plan to implement this but it's not been developed yet.

@jclusso
Copy link

jclusso commented Apr 3, 2019

How does one even use this gem for OAuth in an application with more than one user.

@rgardien
Copy link

I would also be very interested in this addition. Until then I'm just re-initializing the configuration every time.

@jclusso
Copy link

jclusso commented Apr 16, 2019

@rgardien honestly, no offense to the gem, but it seemed overly complicated to add this functionality so I just rolled my own and it was pretty simple.

I don't even understand the purpose of this gem supporting OAuth when it doesn't support dynamic clients.

Anyway I wrote a basic API class and used this OAuth gem to handle the OAuth process. Figured I'd share it here since it may save anyone sometime that needs a dynamic client.

https://gist.github.com/jclusso/cda0df8bd127d716cf1bb859cbf7d008

@rgardien
Copy link

rgardien commented Apr 16, 2019

@jclusso Thanks!

And yes, supporting OAuth without supporting dynamic clients is strange.

@cbisnett
Copy link
Collaborator

I believe the original use-case was for companies to push data to their own Hubspot portals rather than companies developing Hubspot integrations that would need to push data to multiple Hubspot portals.

@jclusso
Copy link

jclusso commented Apr 16, 2019

@cbisnett just not sure why anyone would use OAuth then.

@cbisnett
Copy link
Collaborator

Some of the endpoints require an OAuth token rather than an API key. Creating timeline events is one such endpoint: https://developers.hubspot.com/docs/methods/timeline/create-or-update-event.

@jclusso
Copy link

jclusso commented Apr 16, 2019

@cbisnett ahh that makes sense. That's pretty silly on HubSpot's part, but now it all makes sense. Thanks for pointing that out.

@t-richards
Copy link

I've got an idea for how I plan to implement this but it's not been developed yet.

@cbisnett Any high-level thoughts you'd be willing to share about how you'd like this to be implemented? This feature is important to me and I am willing to help out however possible.

@johnmfarrell1
Copy link

johnmfarrell1 commented Apr 9, 2021

Would also like this feature if possible so would be good to know some ideas. At the moment, I'm trying out wrapping any requests in a block that sets the configuration for the request only and then resets.

  def with_configuration(&block)
    Hubspot.configure(hapikey: <key>)
    response = yield
    Hubspot::Config.reset!
    response
  end
    response = with_configuration { Hubspot::Contact.all }

Would need a little bit more work for OAuth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants