maraujop / requests-oauth

Python's Requests OAuth (Open Authentication) plugin
BSD 3-Clause "New" or "Revised" License
188 stars 33 forks source link

Determining if consumer_key/secret exist #18

Closed michaelhelmick closed 12 years ago

michaelhelmick commented 12 years ago

Say I set

OAuthHook.consumer_key = 'my_consumer_key'
OAuthHook.consumer_secret = 'my_consumer_secret'

It'd be nice if there was a way to determine if consumer_key and consumer_secret were set.

In my case, I want to use a request.session with a hook-pre_request of OAuthHook() using the key/secret if they are set AND if the oauth_token/secret is set when someone initializes my class, I want to then have request.session use the hook-pre_request also passing the oauth_token/secret

Let me know if you need me to elaborate more?

Something like:

if OAuthHook.consumer_key is not None and OAuthHook.consumer_secret is not None:
    self.client = requests.session(hooks={'pre_request': OAuthHook()})

if oauth_token and oauth_secret:  # These are the ones that are passed in my init from maybe a recored in the db
    oauth_hook = OAuthHook(self.oauth_token, self.oauth_secret)
    self.client = requests.session(hooks={'pre_request': oauth_hook})
maraujop commented 12 years ago

Sorry Mike,

I've read this several times and I'm not sure what the question is or what do you want me to do. Remember that the hook doesn't do any connection handling, your binding should take care of this. The hook is coded for let you sign your requests with OAuth1.0. It only intercepts your requests and "signs" them.

Anything beyond this, is something that lives in a separate wrapper on top. Does this seem reasonable?

BTW did you get to test dev branch. I'm quite sure it should fix your issue.

Cheers, Miguel

michaelhelmick commented 12 years ago

No. I've been busy and haven't got to test.

As far as the issue. I just wanted a way to determine of OAuthHook.consumer_key and OAuthHook.consumer_secret were set.

Sent from my iPhone

On Mar 11, 2012, at 1:45 PM, Miguel Araujoreply@reply.github.com wrote:

Sorry Mike,

I've read this several times and I'm not sure what the question is or what do you want me to do. Remember that the hook doesn't do any connection handling, your binding should take care of this. The hook is coded for let you sign your requests with OAuth1.0. It only intercepts your requests and "signs" them.

Anything beyond this, is something that lives in a separate wrapper on top. Does this seem reasonable?

BTW did you get to test dev branch. I'm quite sure it should fix your issue.

Cheers, Miguel


Reply to this email directly or view it on GitHub: https://github.com/maraujop/requests-oauth/issues/18#issuecomment-4440635

michaelhelmick commented 12 years ago

If OAuthHook.consumer_key isn't set. Currently, it won't return None

Sent from my iPhone

On Mar 11, 2012, at 1:45 PM, Miguel Araujoreply@reply.github.com wrote:

Sorry Mike,

I've read this several times and I'm not sure what the question is or what do you want me to do. Remember that the hook doesn't do any connection handling, your binding should take care of this. The hook is coded for let you sign your requests with OAuth1.0. It only intercepts your requests and "signs" them.

Anything beyond this, is something that lives in a separate wrapper on top. Does this seem reasonable?

BTW did you get to test dev branch. I'm quite sure it should fix your issue.

Cheers, Miguel


Reply to this email directly or view it on GitHub: https://github.com/maraujop/requests-oauth/issues/18#issuecomment-4440635

maraujop commented 12 years ago

Hi Mike,

I've set None for default values for consumer_key and consumer_secret. Sorry, to take so long, I should have understood this the first time, your explanation was more than good.

Cheers, Miguel

michaelhelmick commented 12 years ago

Awesome, thanks!

maraujop commented 12 years ago

No problem, thank you!

maraujop commented 12 years ago

Version 0.4.0 has been released, it works well with requests 0.12.1 or higher. I'm closing this issue.

Cheers