Added oauth_verifier arg #162

Merged
hansenrum merged 3 commits from master into master 2013-04-05 09:43:48 -07:00
hansenrum commented 2013-04-04 15:17:25 -07:00 (Migrated from github.com)

Since Twitter now enforces OAuth 1.0a the oauth_verifier attached to the callback_url has to be passed to final authentication via GET. Added a new arg for this.

Since Twitter now enforces OAuth 1.0a the <code>oauth_verifier</code> attached to the <code>callback_url</code> has to be passed to final authentication via <code>GET</code>. Added a new arg for this.
simondlr commented 2013-04-05 09:15:33 -07:00 (Migrated from github.com)

This is the more correct way. +1

This is the more correct way. +1
michaelhelmick commented 2013-04-05 09:25:58 -07:00 (Migrated from github.com)

The oauth_verifier should not be passed through the init; instead it should be passed through the get_authorized_tokens method:

def get_authorized_tokens(self, oauth_verifier):
The `oauth_verifier` should not be passed through the `init`; instead it should be passed through the `get_authorized_tokens` method: ``` python def get_authorized_tokens(self, oauth_verifier): ```
simondlr commented 2013-04-05 09:32:14 -07:00 (Migrated from github.com)

Because it's only used in that case?

Because it's only used in that case?
michaelhelmick commented 2013-04-05 09:43:23 -07:00 (Migrated from github.com)

@simondlr Correct.
@hansenrum Thank you, merging now! I'll push a release sometime today or tomorrow, I have another change I want to add too.

@simondlr Correct. @hansenrum Thank you, merging now! I'll push a release sometime today or tomorrow, I have another change I want to add too.
falcondai commented 2013-04-06 00:06:18 -07:00 (Migrated from github.com)

minor point: you might wanna change the example used in the documentation accordingly.

minor point: you might wanna change the example used in the documentation accordingly.
michaelhelmick commented 2013-04-06 06:24:58 -07:00 (Migrated from github.com)

Thank you, I'll get on that in master branch!

Sent from my iPhone

On Apr 6, 2013, at 3:06 AM, Falcon Dai notifications@github.com wrote:

minor point: you might wanna change the example used in the documentation accordingly.


Reply to this email directly or view it on GitHub.

Thank you, I'll get on that in master branch! Sent from my iPhone On Apr 6, 2013, at 3:06 AM, Falcon Dai notifications@github.com wrote: > minor point: you might wanna change the example used in the documentation accordingly. > > — > Reply to this email directly or view it on GitHub.
ghost commented 2013-04-08 07:20:38 -07:00 (Migrated from github.com)

Can you please update the package in PIP? The change for this isn't in the version thats up there

Can you please update the package in PIP? The change for this isn't in the version thats up there
danxshap commented 2013-04-08 07:29:01 -07:00 (Migrated from github.com)

Yes, a PyPi update would be much appreciated!

Yes, a PyPi update would be much appreciated!
michaelhelmick commented 2013-04-08 07:29:42 -07:00 (Migrated from github.com)

You guys!! 😊 haha
I'll push an update within the hour!

You guys!! :blush: haha I'll push an update within the hour!
michaelhelmick commented 2013-04-08 08:52:14 -07:00 (Migrated from github.com)

Twython 2.7.1 is now available via PyPi!

pip install -I twython

`Twython` 2.7.1 is now available via PyPi! `pip install -I twython`
leopoldsg commented 2013-04-19 09:49:56 -07:00 (Migrated from github.com)

I don't understand where you obtain the oauth_verifer...

I don't understand where you obtain the oauth_verifer...
danxshap commented 2013-04-19 10:00:16 -07:00 (Migrated from github.com)

@leopoldsg it comes in a GET variable called "oauth_verifier" when Twitter redirects to your callback URL after the user authorizes your app. You need to grab it from the request when handling your callback URL.

@leopoldsg it comes in a GET variable called "oauth_verifier" when Twitter redirects to your callback URL after the user authorizes your app. You need to grab it from the request when handling your callback URL.
leopoldsg commented 2013-04-19 13:47:46 -07:00 (Migrated from github.com)

so what code would you write for that get request?
requests.get('callbackurl')?

so what code would you write for that get request? requests.get('callbackurl')?
michaelhelmick commented 2013-04-19 14:26:52 -07:00 (Migrated from github.com)
Authorization URL
from twython import Twython

t = Twython(app_key, app_secret, callback_url='http://google.com')

auth_props = t.get_authentication_tokens()

oauth_token = auth_props['oauth_token']
oauth_token_secret = auth_props['oauth_token_secret']

print 'Connect to Twitter via: %s' % auth_props['auth_url']

Be sure you have a URL set up to handle the callback after the user has allowed your app to access their data, the callback can be used for storing their final OAuth Token and OAuth Token Secret in a database for use at a later date.

Handling the callback
from twython import Twython

# oauth_token_secret comes from the previous step
# if needed, store that in a session variable or something.
# oauth_verifier and oauth_token from the previous call is now REQUIRED # to pass to get_authorized_tokens

# In Django, to get the oauth_verifier and oauth_token from the callback
# url querystring, you might do something like this:
# oauth_token = request.GET.get('oauth_token')
# oauth_verifier = request.GET.get('oauth_verifier')

t = Twython(app_key, app_secret,
            oauth_token, oauth_token_secret)

auth_tokens = t.get_authorized_tokens(oauth_verifier)
print auth_tokens

Then you'd store

auth_tokens['oauth_token']
auth_tokens['oauth_token_secret']

in a database or something

##### Authorization URL ``` python from twython import Twython t = Twython(app_key, app_secret, callback_url='http://google.com') auth_props = t.get_authentication_tokens() oauth_token = auth_props['oauth_token'] oauth_token_secret = auth_props['oauth_token_secret'] print 'Connect to Twitter via: %s' % auth_props['auth_url'] ``` Be sure you have a URL set up to handle the callback after the user has allowed your app to access their data, the callback can be used for storing their final OAuth Token and OAuth Token Secret in a database for use at a later date. ##### Handling the callback ``` python from twython import Twython # oauth_token_secret comes from the previous step # if needed, store that in a session variable or something. # oauth_verifier and oauth_token from the previous call is now REQUIRED # to pass to get_authorized_tokens # In Django, to get the oauth_verifier and oauth_token from the callback # url querystring, you might do something like this: # oauth_token = request.GET.get('oauth_token') # oauth_verifier = request.GET.get('oauth_verifier') t = Twython(app_key, app_secret, oauth_token, oauth_token_secret) auth_tokens = t.get_authorized_tokens(oauth_verifier) print auth_tokens ``` Then you'd store ``` python auth_tokens['oauth_token'] auth_tokens['oauth_token_secret'] ``` in a database or something
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#162
No description provided.