I want to integrate authenticated vimeo user's videos in my web application. I have this code https://gist.github.com/2944212
I made authorize call and now I got oauth_token, oauth_token_secret, oauth_verifier. I added all these things to the parameter and made request to the below url, but now I'm getting this error
>>> url = 'http://vimeo.com/oauth/access_token'
>>> req = oauth.Request(method='GET', url=url, parameters=params)
>>> req.sign_request(signature_method, consumer, token)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 502, in sign_request
self['oauth_signature'] = signature_method.sign(self, consumer, token)
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 838, in sign
key, raw = self.signing_base(request, consumer, token)
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 832, in signing_base
key += escape(token.secret)
AttributeError: 'str' object has no attribute 'secret'
Using that how can I fetch access_token and make this method to work https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded
I'm new to oauth and I need your help.
Thanks!
UPDATE
Now I solved that error. The only thing I need is to get the access token and a script to make the request for this method https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded
If I understand correctly you now have the access token?
To make requests to the API endpoint follow the same procedure but use the access token (as the oauth_token parameter) and in the req.sign method. Direct your request towards the API URL aswell, of course :)
And you don't need the oauth_verifier once you have the access token.
Related
I simply want to post a tweet from my Raspberry Pi and keep getting a 401 error.
-----------------------------------------This is my code-----------------------------------------
import sys
from twython import Twython
consumer_key='x'
consumer_secret='x'
access_token='x'
access_token_secret='x'
twitter = Twython(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
twitter.update_status(status='Test')
----------------------------------------Trace back------------------------------------------------
Traceback (most recent call last):
File "/home/pi/Desktop/Programs/tweetTest.py", line 29, in <module>
twitter.update_status(status='Test')
File "/usr/lib/python3/dist-packages/twython/endpoints.py", line 123, in update_status
return self.post('statuses/update', params=params)
File "/usr/lib/python3/dist-packages/twython/api.py", line 274, in post
return self.request(endpoint, 'POST', params=params, version=version)
File "/usr/lib/python3/dist-packages/twython/api.py", line 264, in request
api_call=url)
File "/usr/lib/python3/dist-packages/twython/api.py", line 199, in _request
retry_after=response.headers.get('X-Rate-Limit-Reset'))
twython.exceptions.TwythonAuthError: Twitter API returned a 401 (Unauthorized), Could not authenticate you
First of all, it appears you have misspelled 'consumer_secret' in your Twython instance: concumer_secret.
Secondly, if you have a desktop app (which I assume you have since this is tagged "raspberry-pi") it looks like you don't need to provide access tokens, just the 'APP_KEY' and 'APP_SECRET'. If you are using the oauth tokens, you might want to provide the code where you are receiving those in case that is the source of the problem.
I am new to the Instagram API. I used the following code from the example on the github to get the most recent popular media.
from instagram.client import InstagramAPI
id= "OMITTED"
secret = "OMITTED"
api = InstagramAPI(client_id=id, client_secret=secret)
popular_media = api.media_popular(count=20)
for media in popular_media:
print media.images['standard_resolution'].url
I get the following error:
File "example.py", line 6, in <module>
popular_media = api.media_popular(count=20)
File "/usr/lib/python2.6/site-packages/instagram/bind.py", line 197, in _call
return method.execute()
File "/usr/lib/python2.6/site-packages/instagram/bind.py", line 189, in execute
content, next = self._do_api_request(url, method, body, headers)
File "/usr/lib/python2.6/site-packages/instagram/bind.py", line 131, in _do_api_request
raise InstagramClientError('Unable to parse response, not valid JSON.', status_code=response['status'])
instagram.bind.InstagramClientError: (404) Unable to parse response, not valid JSON.
I know it is a valid instagram object because when I print(api). I get the following:
<instagram.client.InstagramAPI object at 0x145c2b10>
This is taken directly from the example and I can't tell what I am doing wrong! Any help would be great!
If u signed up after Nov 17th, Instagram popular photo feed is deprecated in new API.
The library you are using is old, it will only work for popular API if you had signed up for before November 17th
https://www.instagram.com/developer/changelog/
I keep getting this error when I tried the examples in the python-instagram documentation:
from instagram.client import InstagramAPI
access_token = "YOUR_ACCESS_TOKEN"
client_secret = "YOUR_CLIENT_SECRET"
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
print media.caption.text
Error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 197, in _call
return method.execute()
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 189, in execute
content, next = self._do_api_request(url, method, body, headers)
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 131, in _do_api_request
raise InstagramClientError('Unable to parse response, not valid JSON.', status_code=response['status'])
InstagramClientError: (404) Unable to parse response, not valid JSON.
I'm not sure what is causing this error. I got my access_token and filled in all the parameters
I get the same error when I try other parts of the documentation:
api = InstagramAPI(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')
popular_media = api.media_popular(count=20)
for media in popular_media:
print media.images['standard_resolution'].url
Ig made some major platform changes (introducing a Sandbox Mode) on Nov 17th that may be affecting your access.
I would check out this thread, from the repo you are using, plenty of SO links there as well.
A suggestion would be to bypass the python API and use curl with something like this for writing a comment (see if you can narrow down your error):
curl -F 'access_token=ACCESS-TOKEN' \
-F 'text=This+is+my+comment' \
https://api.instagram.com/v1/media/{media-id}/comments
Good evening, i've been trying to migrate my blogger python app to oauth2 since the good old Clientlogin() has been deprecated and erased.
So, basically i searched through the entire web and couldn't manage to make my application to work correctly.
This is the basic code im using for testing:
FLOW = flow_from_clientsecrets('/home/b/client_secret.json',scope='https://www.googleapis.com/auth/blogger',message="Client Secrets Not Found")
storage = Storage('blogger.dat')
credentials = storage.get()
parser = argparse.ArgumentParser(parents=[tools.argparser])
flags = parser.parse_args()
if credentials is None or credentials.invalid:
credentials = run_flow(FLOW, storage, flags)
if credentials.access_token_expired:
credentials.refresh(httplib2.Http())
SCOPE = 'https://www.blogger.com/feeds'
token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
client = gdata.blogger.client.BloggerClient()
token.authorize(client)
post = client.add_post(blog_id, title="blah", body="blah", labels="label", draft=False, title_type="xhtml", body_type="html")
I get a 401 error code, unauthorized everytime i try to do this.
Traceback (most recent call last):
File "/home/b/.eclipse/org.eclipse.platform_4.4.2_1473617060_linux_gtk_x86_64/plugins/org.python.pydev_4.0.0.201504132356/pysrc/pydevd.py", line 2278, in <module>
globals = debugger.run(setup['file'], None, None)
File "/home/b/.eclipse/org.eclipse.platform_4.4.2_1473617060_linux_gtk_x86_64/plugins/org.python.pydev_4.0.0.201504132356/pysrc/pydevd.py", line 1704, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/b/workspace/BloggerPy/simpleblogger.py", line 53, in <module>
post = client.add_post(blog_id, title="hola", body="holaaa", labels="label", draft=False, title_type="xhtml", body_type="html", token=token)
File "/usr/local/lib/python2.7/dist-packages/gdata/blogger/client.py", line 111, in add_post
return self.post(new_entry, BLOG_POST_URL % blog_id, auth_token=auth_token, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 690, in post
desired_class=desired_class, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 298, in request
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 307, in request
response, Unauthorized)
gdata.client.Unauthorized: Unauthorized - Server responded with: 401, User does not have permission to create new post
Can someone help me out with this? I'd really appreciate it :)
Greetings
Finally i've fixed my issue with gdata.gauth:
I used auth2token = gdata.gauth.OAuth2Token(client_id,client_secret,scope,user_agent)
After getting the authorization token i generate an authorized url to get an access code with auth2token.generate_authorize_url(redirect_uri=URL,approval_prompt="force").
once you get this url, you manually get the code and generate a refresh token, with which you generate an access token:
token = auth2token.get_access_token(code). Easy enough. For any other information as to how to save the token to a blob string in a file here's the reference:
gdata-python-api + Analytics with simple auth
I am writing this program to get data from twitter of hashtags but it give me the error
import twitter
import json
import urllib
twitter_search = twitter.Twitter(domain="search.twitter.com")
for page in range(1,2):
k_results=twitter_search.search(q="jonson",rpp=100,page=page)
print json.dumps(k_results, sort_keys=True, indent=1)
errors are
Traceback (most recent call last):
File "<pyshell#6>", line 2, in <module>
k_results=twitter_search.search(q="Burma",rpp=100,page=page)
File "build\bdist.win32\egg\twitter\api.py", line 173, in __call__
return self._handle_response(req, uri, arg_data)
File "build\bdist.win32\egg\twitter\api.py", line 198, in _handle_response
raise TwitterHTTPError(e, uri, self.format, arg_data)
TwitterHTTPError: Twitter sent status 410 for URL: search.json using parameters: (q=Burma&rpp=100&page=1)
details: οΎ‹
You try to use API 1.0 endpoint, http://search.twitter.com/search.format. It returns status 410, gone:
When API v1 is finally retired, all authenticated and unauthenticated requests to API v1 will return a HTTP 410 Gone status. Older widgets will receive the same response. This status code signifies that all API v1-era resources are gone and not coming back.
Correct url for 1.1 search is https://api.twitter.com/1.1/search/tweets.json
I don't know whether twitter module you're using is updated to use API 1.1, and suggest to use one of modules that is.