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

Determining if consumer_key/secret exist #18

Closed
michaelhelmick opened this issue Mar 6, 2012 · 7 comments
Closed

Determining if consumer_key/secret exist #18

michaelhelmick opened this issue Mar 6, 2012 · 7 comments
Labels

Comments

@michaelhelmick
Copy link

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
Copy link
Owner

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
Copy link
Author

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:
#18 (comment)

@michaelhelmick
Copy link
Author

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:
#18 (comment)

maraujop added a commit that referenced this issue Mar 17, 2012
@maraujop
Copy link
Owner

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
Copy link
Author

Awesome, thanks!

@maraujop
Copy link
Owner

No problem, thank you!

@maraujop
Copy link
Owner

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

Cheers

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

No branches or pull requests

2 participants