Closed srinivasuk closed 10 years ago
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...
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)
That call alone won't make any output - you need to do something with the results of that call if I'm understanding correctly
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...
you need to put the result of client.info()
into a variable - and then do something with the result:
print client.info()
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': []}
Hmm - that's definitely indicative of incorrect credentials (or possibly given in the wrong order?)
Entered in this order...
Consumer Key Consumer Secret Token Token Secret
And they are the exact values (with no extra spaces) that you get from a fresh, working session on https://api.tumblr.com/console/ ?
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
Yes - it needs to be accepted every time you authenticate
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?
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)
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...
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']
i am using latest Python 2.7.6 hope that is not an issue...
i even kept callback url active...still same issue..
from pytumblr import TumblrRestClient
# Authenticate via OAuth
client = TumblrRestClient(
'Somekeyvalue111111111111111111111',
'Somekeyvalue222222222222222222',
'Somekeyvalue333333333333333333',
'Somekeyvalue444444444444444444'
)
print client.info()
this is my code.
python 2.7.6 should be all good - are all four of your keys the same length?
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...
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
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?
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...
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
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
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...
You must be using the wrong tokens, or in the wrong order
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)
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
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
earlier i have tried it from downloaded package...
now i just reinstalled pytumblr using pip install pytumblr
and then launched the script using
still i got same issue...
can you provide what are the versions of python packages?
[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)
Python 2.7.6 is my python version
do we need to open any ports in firewall?
This client comes with a nice interactive console to run you through the OAuth
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?
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': []}
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:
pip install pytumblr will install the packages you need
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
you don't need to supply any at all
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.…...
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
If your system clock not set to a real time? That is meaningful.
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/tumblr/pytumblr/issues/34#issuecomment-33305728 .
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?
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.
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/tumblr/pytumblr/issues/34#issuecomment-33682657 .
What output do you get when running: 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/tumblr/pytumblr/issues/34#issuecomment-33733072 .
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
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/tumblr/pytumblr/issues/34#issuecomment-33733341 .
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/
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/tumblr/pytumblr/issues/34#issuecomment-33734253 .
No problem - thank you!
thanks closing the issue now...
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'