question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OAuth2Session doesn't use token if netrc is present

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Lukasacommented, May 4, 2017

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

0reactions
ryanhiebertcommented, May 4, 2017

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing access Token parameter with OAuth2Session, but ...
The api I'm hitting isn't public, so I'll do my best to provide context even if you can't directly reproduce. Here's what works...
Read more >
The .netrc file (GNU Inetutils)
Identify a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified name....
Read more >
Git .netrc file authentication issue - Stack Overflow
The ~/.netrc (or %HOME%\_netrc on Windows) file isn't enough. It is best to use that file encrypted, with gpg + netrc alone, as...
Read more >
Simple OAuth2 with Password and Bearer - FastAPI
It doesn't matter if it has other characters like : or if it is a URL. ... and use it as a dependency...
Read more >
.netrc - Everything curl
Note that if this token is present in the .netrc file you really should make sure the file is not readable by anyone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found