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

client error: (401) Unauthorized #65

Closed
actuallybc opened this Issue Sep 22, 2014 · 12 comments

Comments

Projects
None yet
8 participants
@actuallybc

actuallybc commented Sep 22, 2014

While trying to use twitteR interactively in R Studio I got this error... "XXXXXX's" are my key and secret respectively.

library(twitteR)
setup_twitter_oauth("XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
[1] "Using browser based authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

Selection: 1
Error in init_oauth1.0(endpoint, app, permission = params$permission) :
client error: (401) Unauthorized

I would appreciate any help. I have also seen the same question on stackoverflow but no answer was given. I am running R 3.1.1 with httr 0.5.0.90 and twitteR version 1.1.8.

Thanks,

B

@geoffjentry

This comment has been minimized.

Show comment
Hide comment
@geoffjentry

geoffjentry Oct 6, 2014

Owner

Hi -

The first thing I always point people to is the example in httr:
https://github.com/hadley/httr/blob/master/demo/oauth1-twitter.r

If you can get this to work but not twitteR let me know. Normally though people can't make this example work which means that either they're inputting something incorrectly or something else is awry.

Owner

geoffjentry commented Oct 6, 2014

Hi -

The first thing I always point people to is the example in httr:
https://github.com/hadley/httr/blob/master/demo/oauth1-twitter.r

If you can get this to work but not twitteR let me know. Normally though people can't make this example work which means that either they're inputting something incorrectly or something else is awry.

@jdeboer

This comment has been minimized.

Show comment
Hide comment
@jdeboer

jdeboer Oct 28, 2014

I'm experiencing an issue like this too. I've tried the demo in httr, but it reports the same error as above:

Error in init_oauth1.0(endpoint, app, permission = params$permission) : 
  client error: (401) Unauthorized

If I supply the access_token and access_secret when calling setup_twitter_oauth then it works without any errors. Looking at the function definition for setup_twitter_oauth I would say this is because when supplying these optional parameters then init_oauth1.0 does not need to be called as sign_oauth1.0 can be called instead.

jdeboer commented Oct 28, 2014

I'm experiencing an issue like this too. I've tried the demo in httr, but it reports the same error as above:

Error in init_oauth1.0(endpoint, app, permission = params$permission) : 
  client error: (401) Unauthorized

If I supply the access_token and access_secret when calling setup_twitter_oauth then it works without any errors. Looking at the function definition for setup_twitter_oauth I would say this is because when supplying these optional parameters then init_oauth1.0 does not need to be called as sign_oauth1.0 can be called instead.

@lmmx

This comment has been minimized.

Show comment
Hide comment
@lmmx

lmmx Feb 16, 2015

Contributor

Steps that resolved this issue for me :

  • try this httr demo
  • ensure the callback URL on your app is set to http://127.0.0.1:1410 as Hadley explains here
  • install.packages('httpuv') if you can't load it with library('httpuv'), as was the case on my machine
Contributor

lmmx commented Feb 16, 2015

Steps that resolved this issue for me :

  • try this httr demo
  • ensure the callback URL on your app is set to http://127.0.0.1:1410 as Hadley explains here
  • install.packages('httpuv') if you can't load it with library('httpuv'), as was the case on my machine
@geoffjentry

This comment has been minimized.

Show comment
Hide comment
@geoffjentry

geoffjentry Feb 16, 2015

Owner

@jdeboer - check out the suggestions from @lmmx

If that doesn't solve things and you're experiencing the same issues with httr you'll need to talk to Hadley.

Owner

geoffjentry commented Feb 16, 2015

@jdeboer - check out the suggestions from @lmmx

If that doesn't solve things and you're experiencing the same issues with httr you'll need to talk to Hadley.

@aravinthan6206

This comment has been minimized.

Show comment
Hide comment
@aravinthan6206

aravinthan6206 Jul 7, 2015

I am able to execute the demo without any error. I am facing problems with twitteR. If I give the callback url, then I am unable to see the page which displays the PIN. I have tried this in Chrome as well as IE. IE gives 'Page cannot be displayed' error and chrome gives 'ERR_CONNECTION_REFUSED'. If I dont give the callback url, I am able to see the PIN but run into problems in the next step. This has become kind of cyclical. Without callback url I am able to complete one extra step.

aravinthan6206 commented Jul 7, 2015

I am able to execute the demo without any error. I am facing problems with twitteR. If I give the callback url, then I am unable to see the page which displays the PIN. I have tried this in Chrome as well as IE. IE gives 'Page cannot be displayed' error and chrome gives 'ERR_CONNECTION_REFUSED'. If I dont give the callback url, I am able to see the PIN but run into problems in the next step. This has become kind of cyclical. Without callback url I am able to complete one extra step.

@aravinthan6206

This comment has been minimized.

Show comment
Hide comment
@aravinthan6206

aravinthan6206 Jul 7, 2015

@geoffjentry .. I found a way to work around the problem. I created the app without giving the callback url. After entering the PIN, I modified the app settings to have http://127.0.0.1:1410 as my callback url. If I follow the above mentioned steps I was able to successfully make a connection with twitter and able to download tweets. Is there any way to make this work directly without having to modify the app settings after entering the pin? Am I having this problem due to any network issues?

aravinthan6206 commented Jul 7, 2015

@geoffjentry .. I found a way to work around the problem. I created the app without giving the callback url. After entering the PIN, I modified the app settings to have http://127.0.0.1:1410 as my callback url. If I follow the above mentioned steps I was able to successfully make a connection with twitter and able to download tweets. Is there any way to make this work directly without having to modify the app settings after entering the pin? Am I having this problem due to any network issues?

@geoffjentry

This comment has been minimized.

Show comment
Hide comment
@geoffjentry

geoffjentry Jul 7, 2015

Owner

You're almost certainly seeing the same issue as #90 - I'm going to close this as the original issue has gone stale and to consolidate the conversation there

Owner

geoffjentry commented Jul 7, 2015

You're almost certainly seeing the same issue as #90 - I'm going to close this as the original issue has gone stale and to consolidate the conversation there

@geoffjentry geoffjentry closed this Jul 7, 2015

@jimenezgdavid

This comment has been minimized.

Show comment
Hide comment
@jimenezgdavid

jimenezgdavid Sep 21, 2015

Be sure to > install.packages('httpuv'). That was the issue for me.

jimenezgdavid commented Sep 21, 2015

Be sure to > install.packages('httpuv'). That was the issue for me.

@rakesh-roshan

This comment has been minimized.

Show comment
Hide comment
@rakesh-roshan

rakesh-roshan Oct 6, 2015

I got it fixed by manually generating access token at apps.twitter.com site and pass that as argument to the api which will force to use local authentication rather than browser authentication.

rakesh-roshan commented Oct 6, 2015

I got it fixed by manually generating access token at apps.twitter.com site and pass that as argument to the api which will force to use local authentication rather than browser authentication.

@j450h1

This comment has been minimized.

Show comment
Hide comment
@j450h1

j450h1 Jun 14, 2016

Tried all the approaches above and still getting HTTP 401. I hope I don't have to implement this in Python :(

j450h1 commented Jun 14, 2016

Tried all the approaches above and still getting HTTP 401. I hope I don't have to implement this in Python :(

@jdeboer

This comment has been minimized.

Show comment
Hide comment
@jdeboer

jdeboer Jun 14, 2016

If you end up using Python, I recommend the tweepy module. I used it recently and found it to be quite easy. If it help, you can access Python from R or the other way around if you like.

jdeboer commented Jun 14, 2016

If you end up using Python, I recommend the tweepy module. I used it recently and found it to be quite easy. If it help, you can access Python from R or the other way around if you like.

@j450h1

This comment has been minimized.

Show comment
Hide comment
@j450h1

j450h1 Jun 14, 2016

Thanks for suggestion. I just solved the issue. Both of these need to be unchecked in the app settings:

  • Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)
  • Allow this application to be used to Sign in with Twitter

j450h1 commented Jun 14, 2016

Thanks for suggestion. I just solved the issue. Both of these need to be unchecked in the app settings:

  • Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)
  • Allow this application to be used to Sign in with Twitter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment