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

OAuth2Session doesn't use token if netrc is present #278

Closed
ryanhiebert opened this issue May 4, 2017 · 5 comments
Closed

OAuth2Session doesn't use token if netrc is present #278

ryanhiebert opened this issue May 4, 2017 · 5 comments

Comments

@ryanhiebert
Copy link
Contributor

ryanhiebert commented May 4, 2017

The Heroku Toolbelt client uses a .netrc file to store its credentials locally. When using OAuth2Session, giving a properly-formed token to the constructor, the auth property on the session is not set, and requests goes and looks for a netrc file to add them in automatically when the request is made. When we have set the token, this really needs to not happen.

The "ideal" fix would be to have the OAuth2Session.auth property set to OAuth2. I definitely don't know the complexities of how difficult this is, but this bug makes OAuth2Session unusable for me, and I'm having to drop down to using OAuth2 auth directly instead for my use-case.

@Lukasa
Copy link
Member

Lukasa commented May 4, 2017

Yeah, this is a moderate annoyance. Probably a better fix is to provide a no-op auth handler that can deal with this.

@ryanhiebert
Copy link
Contributor Author

ryanhiebert commented May 4, 2017

That makes sense. I'm thinking that it wouldn't need to be exposed as a public API, since it's just a way of saying "we've already got authentication covered, don't mess with us".

Could that be added universally in the init method, or do we need to add it conditionally, when we have a token to use? If we need to do it selectively, we'll likely need to set and unset it in several places.

@Lukasa
Copy link
Member

Lukasa commented May 4, 2017

Selectively, sadly. There are some situations where we deliberately use basic auth or other auth handlers.

@ryanhiebert
Copy link
Contributor Author

I was thinking that those cases could be handled the same as with a standard Session, by initializing it with the No-op auth, and then setting the auth after initialization. This is exactly what's required from a normal Session anyway.

session = OAuth2Session(token=token)
session.auth = MyAuth()

Are you saying that there's further complexity within requests-oauthlib that makes that pattern unsuitable?

@Lukasa
Copy link
Member

Lukasa commented May 4, 2017

That's certainly possible. Worth seeing how that looks in the code, at any rate.

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

2 participants