Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

Allow to use custom session object #37

Closed
tspng opened this issue Apr 29, 2015 · 3 comments
Closed

Allow to use custom session object #37

tspng opened this issue Apr 29, 2015 · 3 comments

Comments

@tspng
Copy link
Contributor

tspng commented Apr 29, 2015

As of v1 it seems that's impossible to pass a custom session object.
Is it possible to extend Navigator.hal() method to accept a session object?

As of now, v1 doesn't work for me yet, because I need OAuth2 authentication with a custom ca bundle file.

Please tell me if you wan't me to submit a pull request.

Cheers.

@bubenkoff
Copy link
Collaborator

Two hands for PR :)
On Apr 29, 2015 4:19 PM, "haestan" notifications@github.com wrote:

As of v1 it seems that's impossible to pass a custom session object.
Is it possible to extend Navigator.hal() method to accept a session object?

As of now, v1 doesn't work for me yet, because I need OAuth2
authentication with a custom ca bundle file.

Please tell me if you wan't me to submit a pull request.

Cheers.


Reply to this email directly or view it on GitHub
#37.

@deontologician
Copy link
Owner

So, the Navigator.hal factory method is just for convenience, since the constructor to HALNavigator is kind of annoying to use. But, if you're willing to construct your own APICore object, you can do it:

from restnavigator.halnav import APICore, HALNavigator, Link
from restnavigator import utils
from requests_oauthlib import OAuth2Session

N = HALNavigator(
    link=Link(uri=root_uri),
    core=APICore(
        root=root,
        nav_class=HALNavigator,
        apiname=apiname,
        default_curie=default_curie,
        session=OAuth2Session(
            r'client_id', token='token', cert="/path/to/custom_certs.pem"),
    )
)

I agree though, this is a pain in the ass and should be easier given how common OAuth is. I would happily accept pull requests if you'd like to add a session keyword argument to the Navigator.hal factory method.

@deontologician
Copy link
Owner

Fixed by #38

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

No branches or pull requests

3 participants