Skip to content

Adds client certificate parameter to OAuth2Session - #293

Closed
amackera wants to merge 2 commits into
requests:masterfrom
AdaSupport:master
Closed

amackera wants to merge 2 commits into
requests:masterfrom
AdaSupport:master

Conversation

@amackera

Copy link
Copy Markdown

This allows users to specify a client certificate to pass to requests. This is useful for some OAuth providers that require client certificate authentication.

@amackera

Copy link
Copy Markdown
Author

Related issue: #292

@Lukasa

Lukasa commented Oct 18, 2017

Copy link
Copy Markdown
Member

Requests should do this automatically: did you actually try using the cert argument in this way?

@amackera

Copy link
Copy Markdown
Author

Hi @Lukasa yes, we tried using the cert argument, but it did not work. It's been a while since I looked at this issue though so my memory could be faulty!

Feel free to close this PR if y'all know for a fact that requests-oauthlib supports client certificates out of the box.

@ltamaster

Copy link
Copy Markdown

I had the same problem, I tried to use the certargument without luck.
Any advice on how to pass the certificate?

Thanks
Luis

@sserrata

sserrata commented Feb 21, 2018 •

Copy link
Copy Markdown

I've confirmed that the cert parameter works as either a kwarg, e.g. oauth2session.fetch_token(cert='cert.pem') or as an OAuth2Session() attribute, e.g. oauth2session.cert = 'cert.pem', with the former overriding the latter (as expected).

@ltamaster

Copy link
Copy Markdown

I tried oauth2session.cert =tmp-cert-path and oauth2session.refresh_token(****, cert=tmp-cert-path) without luck, any ideas?
the certificate works ok on other calls (i am working with kubernetes sdk)

@singingwolfboy

Copy link
Copy Markdown
Member

So, it sounds like @amackera and @ltamaster are unable to pass the cert parameter without this change, but @sserrata was able to use it even without this change. Is that correct? @sserrata, any idea why it works for you but not for them?

It seems cleaner to let Requests do the proxying automatically, so if we can avoid having to make this change, that seems preferable. But if it's not possible to do that proxying automatically, then I guess we do need this change.

@calcium

calcium commented Jul 16, 2018

Copy link
Copy Markdown

I just cloned the current trunk (master) and looking at the code for fetch_token
oauth2_session.py:219
if method.upper() == 'POST':
r = self.post(token_url, data=dict(urldecode(body)),
timeout=timeout, headers=headers, auth=auth,
verify=verify, proxies=proxies)

I dont see how this would work as is without the extra cert args.

Yes, I need to do this too :-)

@Anmol-Porwal18

Copy link
Copy Markdown

Hi, Is using oauth2session.cert the expected way to pass certificates ?

I need this functionality too (to be able to pass certificate in fetch_token - which will take care of passing it further). Are we expecting this to be merged soon ?

@amackera

Copy link
Copy Markdown
Author

Closing this (years old) PR due to lack of activity.

@amackera amackera closed this Aug 24, 2021
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

Successfully merging this pull request may close these issues.

8 participants