OAuth get_access_token 401 issue...

66 views
Skip to first unread message

space0x42

unread,
Dec 15, 2009, 6:43:30 AM12/15/09
to tweepy
Hi all

I'm probably missing something quite obvious, but I can't have OAuth
authentication working...

I already integrated our system backend with twitter using tweepy and
basic authentication and it woks like a charm... now the time come to
activate also OAuth support and I've been banging my head on this all
the morning with no result... :(

I first referred to the authentication tutorial:

http://joshthecoder.github.com/tweepy/docs/auth_tutorial.html#oauth-authentication

-I registered an app with Twitter and apparently got it accepted:
http://twitter.com/oauth_clients/details/55084
-switched to python comend line and did the following:

>>> import tweepy
>>> consumer_token='vIuelbJF4vYxQjMjKkVuA'
>>> consumer_secret='owgLq8kIJx0eWjdzMeZxIjCL4dXHMxANoelRwNozOw'
>>> auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
>>> redirect_url = auth.get_authorization_url()

(I already regenerated key and secret, so testing with these now will
anyway result in an error)

But what I every time get is a 401 error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/www/erm/lib/tweepy/auth.py", line 95, in
get_authorization_url
raise TweepError(e)
tweepy.error.TweepError: HTTP Error 401: Unauthorized

I tracked down the issue to line 67 of auth.py:

resp = urlopen(Request(self.REQUEST_TOKEN_URL,
headers=request.to_header()))

I also tried the guestaccesstoken.py example:

http://github.com/joshthecoder/tweepy-examples/blob/master/oauth/getaccesstoken.py

But with the very same frustrating result...

>virtualdebian:/var/www/erm/lib# python test.py
>Consumer key: vIuelbJF4vYxQjMjKkVuA
>Consumer secret: owgLq8kIJx0eWjdzMeZxIjCL4dXHMxANoelRwNozOw
>Traceback (most recent call last):
> File "test.py", line 17, in <module>
> webbrowser.open(auth.get_authorization_url())
> File "/var/www/erm/lib/tweepy/auth.py", line 95, in get_authorization_url
> raise TweepError(e)
>tweepy.error.TweepError: HTTP Error 401: Unauthorized

Am I missing something obvious? This is stopping me from proceeding
with the integration :(

Any help will be appreciated, thanks

Simone

Josh Roesslein

unread,
Dec 15, 2009, 12:34:25 PM12/15/09
to twe...@googlegroups.com
Hey Simone,

I just tested with your consumer credentials and get the unauthorized
error as well. I am guessing
this means the credentials are incorrect or the app is not configured
correctly. Can you provide the configuration
details of your oauth application from the oauth_client page.

Also do not share your consumer credentials if you plan to use them in
production. It's not a good idea.

Thanks for your interest in Tweepy.

Josh

unknownerror

unread,
Jan 1, 2010, 4:28:49 AM1/1/10
to tweepy
I also am having the same problem. Was their any resolution to
Simone's problem? I was just creating a simple dummy test app. to try
the examples and could not get it working...

-Brandon

On Dec 15 2009, 9:34 am, Josh Roesslein <jroessl...@gmail.com> wrote:
> Hey Simone,
>
> I just tested with your consumer credentials and get the unauthorized
> error as well. I am guessing
> this means the credentials are incorrect or the app is not configured
> correctly. Can you provide the configuration
> details of your oauth application from the oauth_client page.
>
> Also do not share your consumer credentials if you plan to use them in
> production. It's not a good idea.
>
> Thanks for your interest in Tweepy.
>
> Josh
>

> On Tue, Dec 15, 2009 at 5:43 AM, space0x42 <simone.bett...@gmail.com> wrote:
> > Hi all
>
> > I'm probably missing something quite obvious, but I can't have OAuth
> > authentication working...
>
> > I already integrated our system backend with twitter using tweepy and
> > basic authentication and it woks like a charm... now the time come to
> > activate also OAuth support and I've been banging my head on this all
> > the morning with no result... :(
>
> > I first referred to the authentication tutorial:
>

> >http://joshthecoder.github.com/tweepy/docs/auth_tutorial.html#oauth-a...


>
> > -I registered an app with Twitter and apparently got it accepted:
> >http://twitter.com/oauth_clients/details/55084
> > -switched to python comend line and did the following:
>
> >>>> import tweepy
> >>>> consumer_token='vIuelbJF4vYxQjMjKkVuA'
> >>>> consumer_secret='owgLq8kIJx0eWjdzMeZxIjCL4dXHMxANoelRwNozOw'
> >>>> auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
> >>>> redirect_url = auth.get_authorization_url()
>
> > (I already regenerated key and secret, so testing with these now will
> > anyway result in an error)
>
> > But what I every time get is a 401 error:
>
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in <module>
> >  File "/var/www/erm/lib/tweepy/auth.py", line 95, in
> > get_authorization_url
> >    raise TweepError(e)
> > tweepy.error.TweepError: HTTP Error 401: Unauthorized
>
> > I tracked down the issue to line 67 of auth.py:
>
> >            resp = urlopen(Request(self.REQUEST_TOKEN_URL,
> > headers=request.to_header()))
>
> > I also tried the guestaccesstoken.py example:
>

> >      http://github.com/joshthecoder/tweepy-examples/blob/master/oauth/geta...

Josh Roesslein

unread,
Jan 1, 2010, 11:00:05 AM1/1/10
to twe...@googlegroups.com
Hi Brandon,

I am not sure if Simone ever got this issue resolved. It seems it
might be something on twitter's end.
I have not had this issue myself or have had any recent reports
besides your own. Might not hurt
to fire off an email to a...@twitter.com and explain the issue. I am
not sure what would be causing the 401
from Tweepy. Give them the account your using to register the app and
the app name. They should be able
to check if everything is okay. Let me know what they say.

Thanks,

Josh

Reply all
Reply to author
Forward
0 new messages