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

oauth issue #34

Closed
srinivasuk opened this issue Jan 23, 2014 · 50 comments
Closed

oauth issue #34

srinivasuk opened this issue Jan 23, 2014 · 50 comments

Comments

@srinivasuk
Copy link

Hello,

I received this error when i launched

python interactive_console.py

I did give correct "consumer key" and "consumer secret" when prompted

I am using latest python and installed required modules it requested using
python setup.py install
Python 2.7.6

Appreciate your help...

Traceback (most recent call last):
File "interactive_console.py", line 65, in
tokens = new_oauth(yaml_path)
File "interactive_console.py", line 32, in new_oauth
print '\nPlease go here and authorize:\n%s?oauth_token=%s' % (authorize_url, request_token['oauth_token'][0])
KeyError: 'oauth_token'

@srinivasuk
Copy link
Author

Finally i was able to get the tests to work...

====
Ran 28 tests in 0.064s

OK
===

but when i try to call

import pytumblr

# Authenticate via OAuth
client = pytumblr.TumblrRestClient(
  'correctvalueentered',
  'correctvalueentered',
  'correctvalueentered',
  'correctvalueentered'
)

# Make the request
client.info() # Grabs the current user information

above calls give blank output...


pip list

distribute (0.6.49)
httplib2 (0.8)
httpretty (0.7.1)
mock (1.0.1)
nose (1.3.0)
oauth2 (1.5.211)
pip (1.5.1)
PyTumblr (0.0.5)
PyYAML (3.10)
setuptools (0.6c11)
urllib3 (1.7.1)
wsgiref (0.1.2)

@seejohnrun
Copy link
Contributor

That call alone won't make any output - you need to do something with the results of that call
if I'm understanding correctly

@srinivasuk
Copy link
Author

client.info() i thought it is supposed to spit out the connected client information...

infact i tried to change the credentials to see if it works...it didn't through any error...and showed not output message still...

i was expecting out is spitted out as shown in this url...

https://api.tumblr.com/console//calls/user/info

@srinivasuk srinivasuk reopened this Jan 23, 2014
@seejohnrun
Copy link
Contributor

you need to put the result of client.info() into a variable - and then do something with the result:

print client.info()

@srinivasuk
Copy link
Author

thanks..my bad....

now i get this blank info...even though i have given correct credentials...

{u'meta': {u'status': 401, u'msg': u'Not Authorized'}, u'response': []}

@seejohnrun
Copy link
Contributor

Hmm - that's definitely indicative of incorrect credentials (or possibly given in the wrong order?)

@srinivasuk
Copy link
Author

Entered in this order...

Consumer Key
Consumer Secret
Token
Token Secret

@seejohnrun
Copy link
Contributor

And they are the exact values (with no extra spaces) that you get from a fresh, working session on
https://api.tumblr.com/console/ ?

@seejohnrun
Copy link
Contributor

are your calls running successfully in the API console? You may need to open a new browser session and reauthenticate
I'm running the exact same code without issue here

@seejohnrun
Copy link
Contributor

Yes - it needs to be accepted every time you authenticate

@srinivasuk
Copy link
Author

the call i am making is from linux machine...from command line..

basically i am not calling from the web page...will the api work?

i made a tinfo.py and calling from shell

python tinfo.py

is it supposed to work from command line like this?

@seejohnrun
Copy link
Contributor

Of course - that's what the API is for. I'm asking if the example calls with the same credentials are working properly from the tumblr API console website (I'm trying to verify that the credentials you have are valid)

@srinivasuk
Copy link
Author

it should be...as the api credentials i have taken from tumblr website...

only thing is callback url that i have mentioned in the api i didn't configured it...would that be any cause of this issue?

when i clicked on the explore api, it gives authentication message with prompt like shown and all examples give correct results in the tumblr console...on the top right i see api keys buttons..i took those four values from there and pasted into the python file...

@seejohnrun
Copy link
Contributor

nope the callback URL won't matter.
I'm running the same code here with no issue - you may want to try creating a new app or just checking things over again:

from pytumblr import TumblrRestClient

client = TumblrRestClient(
    'consumer_key',
    'consumer_secret',
    'token',
    'token_secret'
)

print client.info()['user']['name']

@srinivasuk
Copy link
Author

i am using latest Python 2.7.6
hope that is not an issue...

i even kept callback url active...still same issue..

@srinivasuk
Copy link
Author

from pytumblr import TumblrRestClient

# Authenticate via OAuth
client = TumblrRestClient(
  'Somekeyvalue111111111111111111111',
  'Somekeyvalue222222222222222222',
  'Somekeyvalue333333333333333333',
  'Somekeyvalue444444444444444444'
)

print client.info()

this is my code.

@seejohnrun
Copy link
Contributor

python 2.7.6 should be all good - are all four of your keys the same length?

@srinivasuk
Copy link
Author

yes...all 4 keys same length

also is it anything to do with oauth2?

how can i enable debug call trace to see what is going on...

@srinivasuk
Copy link
Author

i just registered another account with tumbler and signed up new api app

and changed the keys...still the result same...

probably i will try from different machine in my next run

@srinivasuk
Copy link
Author

i just tried another machine...still same error...

is there any other way it can take the properties from?

~/.tumblr is not created for me why?

@srinivasuk
Copy link
Author

when i run interactive-console.py it gives below message and exits

# python tests/test_pytumblr.py
............................
----------------------------------------------------------------------
Ran 28 tests in 0.079s

OK

No tokens are stored in ~/.tumblr as mentioned in the README file...

also i changed the values of keys in the tumblr_credentials.json and kept some dummy values still it says the same result as if it is successful...looks like something fundamentally missing which i can't figure out...

@srinivasuk
Copy link
Author

python setup.py test

when i ran above command i got below error...

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
    info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
    info('process shutting down')
TypeError: 'NoneType' object is not callable

@srinivasuk
Copy link
Author

running build_ext
/usr/local/lib/python2.7/site-packages/nose/config.py:262: RuntimeWarning: Option 'with-coverage' in config file 'setup.cfg' ignored: excluded by runtime environment
  warn(msg, RuntimeWarning)
/usr/local/lib/python2.7/site-packages/nose/config.py:262: RuntimeWarning: Option 'cover-html' in config file 'setup.cfg' ignored: excluded by runtime environment
  warn(msg, RuntimeWarning)
/usr/local/lib/python2.7/site-packages/nose/config.py:262: RuntimeWarning: Option 'cover-package' in config file 'setup.cfg' ignored: excluded by runtime environment
  warn(msg, RuntimeWarning)

got this error in second machine

@srinivasuk
Copy link
Author

i tried it with php application as well...i can access api calls which doesn't need authentication such as avatar etc. but i am not able to access anything which needs API Key or oAUTH based authentication privileges...

@seejohnrun
Copy link
Contributor

You must be using the wrong tokens, or in the wrong order

@seejohnrun
Copy link
Contributor

On my machine with python 2.7.5 that code prints out 'netzeta-kota' - it's odd that you're not getting an import error.
Anything else special about your environment or how you're running this script?

You should delete that app now (really)

@srinivasuk
Copy link
Author

that is dummy app...i will delete it once finished testing...

why we need to get import error?

it is amazon AWS EC2 instance, installed latest python and installed packages through pip

@seejohnrun
Copy link
Contributor

installed packages? are you running pip install pytumblr to install? Otherwise maybe there are version issues
I just did the same on 2.7.5 and got proper output

@srinivasuk
Copy link
Author

earlier i have tried it from downloaded package...

now i just reinstalled pytumblr using pip install pytumblr

and then launched the script using

#python script.py

still i got same issue...

@srinivasuk
Copy link
Author

can you provide what are the versions of python packages?

pip list

[root@aws.zetaclouds.com .softroot]# pip list
distribute (0.6.49)
httplib2 (0.8)
httpretty (0.7.1)
mock (1.0.1)
nose (1.3.0)
oauth2 (1.5.211)
oauthlib (0.6.1)
pip (1.5.1)
python-tumblpy (1.0.2)
PyTumblr (0.0.5)
PyYAML (3.10)
rauth (0.6.2)
requests (1.2.2)
requests-oauthlib (0.3.2)
setuptools (0.6c11)
urllib3 (1.7.1)
wsgiref (0.1.2)

@srinivasuk
Copy link
Author

Python 2.7.6 is my python version

@srinivasuk
Copy link
Author

do we need to open any ports in firewall?

@srinivasuk
Copy link
Author

BTW, the token that i used are the tokens from the tumblr site, as i shared in the snapshot. But in the Readme file i see below line...

This client comes with a nice interactive console to run you through the OAuth

process, grab your tokens (and store them for future use).

does that mean i need to use tokens generated from the interactive console? but you mentioned you were able to run my code with no problem...

now i have 2 questions...

what are the required modules and their versions? (i shared my pip list, please check )

will there be any firewall block oauth?

also the feedback url that i gave in the configuring the app can that be some dummy url?

@srinivasuk
Copy link
Author

i have got interactive console working by copying the ~/.tumblr with the keys

I executed the client.info() from there and it still gave the same error...

(InteractiveConsole)

client.info()
{u'meta': {u'status': 401, u'msg': u'Not Authorized'}, u'response': []}

@seejohnrun
Copy link
Contributor

The console OAuth process and the api.tumblr.com process are exactly the same thing - all they do is walk you through the same process in different ways. Once you have the keys there is no difference.

Now, to answer your 3 questions:

what are the required modules and their versions? (i shared my pip list, please check )

pip install pytumblr will install the packages you need

will there be any firewall block oauth?

no - but the machine needs to be able to call out to other hosts - which I think is fine because
you're able to make calls like /avatar

also the feedback url that i gave in the configuring the app can that be some dummy url?

you don't need to supply any at all

@srinivasuk
Copy link
Author

I tried uninstalling and we installing several times, on 2 different machines on amazon ec2, the behaviour is the same.....I am suspecting it is oauth issue....

Can you please give your

Pip list

Output so I can compare packages and versions.…...

@srinivasuk
Copy link
Author

i used some other program, got this error...

i got 401 error with oauth time stamp issue...do you know how to fix this kind of issue? most likely this is causing oauth to fail...

raise TumblpyAuthError('Seems something couldn't be verified with your OAuth junk. Error: %s, Message: %s' % (response.status_code, response.content))
tumblpy.exceptions.TumblpyAuthError: Seems something couldn't be verified with your OAuth junk. Error: 401, Message: oauth_timestamp is too far away; we believe it is now 1390667052, you sent 1390645441, 21611 seconds away

@seejohnrun
Copy link
Contributor

If your system clock not set to a real time? That is meaningful.

@srinivasuk
Copy link
Author

what you mean by not set to real time...

when i type date it gives correct date...but i still get lag of 6 hours
from api server from tumblr

On Sat, Jan 25, 2014 at 6:58 PM, John Crepezzi notifications@github.comwrote:

If your system clock not set to a real time? That is meaningful.


Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-33305728
.

@srinivasuk
Copy link
Author

still couldn't find solution why tumblr api fails even after date command on my server gives correct time...what you meant by real time setting of the time? is your system configured with UTC zone?

@seejohnrun
Copy link
Contributor

Not the time zone, the actual time.
If it is off, you could get OAuth errors, because the timestamp would be behind.

IE: from your error: oauth_timestamp is too far away; we believe it is now 1390667052, you sent 1390645441, 21611 seconds away

That's 6 hours behind the timestamp that should have been received by the server.

@srinivasuk
Copy link
Author

the thing is the time seen in the server is exactly same as my local
machine...i even sysnced the clocks on the server using the time sync
program...it didn't have much impact...

On Thu, Jan 30, 2014 at 6:18 AM, John Crepezzi notifications@github.comwrote:

Not the time zone, the actual time.
If it is off, you could get OAuth errors, because the timestamp would be
behind.

IE: from your error: oauth_timestamp is too far away; we believe it is now
1390667052, you sent 1390645441, 21611 seconds away

That's 6 hours behind the timestamp that should have been received by the
server.

Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-33682657
.

@seejohnrun
Copy link
Contributor

What output do you get when running: date +%s

@srinivasuk
Copy link
Author

date +%s

1391094277

On Thu, Jan 30, 2014 at 3:03 PM, John Crepezzi notifications@github.comwrote:

What output do you get when running: date +%s

Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-33733072
.

@seejohnrun
Copy link
Contributor

That corresponds to: 1/30/2014 10:04:37 AM GMT-5 (UTC Thu, 30 Jan 2014 15:04:37 GMT)
Your clock is off by 6 hours

@srinivasuk
Copy link
Author

how do we fix it?

On Thu, Jan 30, 2014 at 3:06 PM, John Crepezzi notifications@github.comwrote:

That corresponds to: 1/30/2014 10:04:37 AM GMT-5 (UTC Thu, 30 Jan 2014
15:04:37 GMT)
Your clock is off by 6 hours

Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-33733341
.

@seejohnrun
Copy link
Contributor

Ideally you're going to set up to synchronize with an NTP server somewhere:
http://www.justin.my/2011/04/how-to-synchronize-date-and-time-in-linux-console/

@srinivasuk
Copy link
Author

finally....it works now...i was able to access tumblr server...

thanks for your help...

Note: code didn't give appropriate error message, i have to find the time
lag error from different python package

On Thu, Jan 30, 2014 at 3:16 PM, John Crepezzi notifications@github.comwrote:

Ideally you're going to set up to synchronize with an NTP server somewhere:

http://www.justin.my/2011/04/how-to-synchronize-date-and-time-in-linux-console/

Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-33734253
.

@seejohnrun
Copy link
Contributor

No problem - thank you!

@srinivasuk
Copy link
Author

thanks closing the issue now...

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

No branches or pull requests

2 participants