GithubHelp home page GithubHelp logo

Is there OAuth 2 support? about hubspot3 HOT 7 CLOSED

Nusnus avatar Nusnus commented on July 19, 2024
Is there OAuth 2 support?

from hubspot3.

Comments (7)

jpetrucciani avatar jpetrucciani commented on July 19, 2024 3

This should now be on pip as version 3.2.2!

I'll go ahead and close this issue, but feel free to open it back up if you have any more issues!

from hubspot3.

Nusnus avatar Nusnus commented on July 19, 2024 1

Hey @jpetrucciani , your latest commit fixes the bug!
I can finally do contacts.ContactsClient(access_token=hubspotSession['accessToken'], refresh_token=hubspotSession['refreshToken'], debug=True) and it works as I expect including building the headers as defined in their official docs (checking with debug=True) and basically everything works exactly as if I used the API key method!

Well done mate!

from hubspot3.

jpetrucciani avatar jpetrucciani commented on July 19, 2024

You should be able to use an access_token and a refresh_token instead of an api_key when initializing any of the clients!

def __init__(
self,
api_key=None,
timeout=10,
mixins=None,
access_token=None,
refresh_token=None,
client_id=None,
**extra_options
):

Example:

# instead of:
deals_client = DealsClient(api_key=API_KEY)

# you can do:
deals_client = DealsClient(access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN)

You should be able to do this with any of the current clients!

from hubspot3.

Nusnus avatar Nusnus commented on July 19, 2024

It doesn't work unfortunately.
It sets the access token in the URL itself instead of in the header so it doesn't work (should have Authorization: Bearer {token} header).

Also, I see the utils.refresh_access_token() uses an outdated endpoint.
See here: https://developers.hubspot.com/docs/methods/oauth2/refresh-access-token

I actually need to use the OAuth authentication method and I really like to use the library so I won't have to manually implement all of the clients you've already implemented.

Would it be possible to release a quick fix for this please?

Thanks!

from hubspot3.

jpetrucciani avatar jpetrucciani commented on July 19, 2024

Hmm, sorry about that! I haven't had to use the OAuth methods yet so that functionality hasn't been touched in a while.

I've pushed some small fixes for that that should work (12937eb), however, I don't currently have access to an OAuth setup to test it out. I've basically just changed it to the newer refresh endpoint, and added that Authorization header instead of appending the access_token to the params.

If you could pull that commit down locally to test and let me know if that works the way you are expecting, I can push that to pip!

from hubspot3.

Nusnus avatar Nusnus commented on July 19, 2024

Sure man! Be glad to help - win-win situation here ;)

Seems there's a bug in the commit - will comment there with the technical part.
Once fixed just LMK and I'll pull the commit and test again.

from hubspot3.

jpetrucciani avatar jpetrucciani commented on July 19, 2024

Awesome! I'll get this fix deployed to pip soon

from hubspot3.

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.