Weibo API auth error - python

I started to write a project for Sina Weibo and got a problem from the start.
When I make a get request to API:
http://api.t.sina.com.cn/statuses/public_timeline.json?source=App_key&count=5
I get an error of authentication such as:
{"request":"/statuses/public_timeline.json","error_code":"403","error":"40070:Insufficient app permissions!"}
or another request and answer:
https://api.weibo.com/2/statuses/user_timeline.json?source=Appkey&trim_user=1&count=100&screen_name=michael
{"error":"applications over the unaudited use restrictions!","error_code":21321,"request":"/2/statuses/user_timeline.json"}
Can someone help me to make this request work?
I just don't het If I need to send token somehow or secret-key.. I am new at development and would be glad if someone answers.

Probably to late, but for future uses. Weibo requires all request to be OAuth2 authenticated. So before using that you need to give permissions and generate access tokens. It's common practice. Services like twitter provide smaller limits also for unauthenticated users, to ease developer live, however that's not the case with weibo :(
If you are working with weibo I highly recommend this article ->
https://www.cs.cmu.edu/~lingwang/weiboguide/

Related

Stuck with oauth when trying audiomack api

All I know about API authentication is just password and bearer token. (and NO AUTH too ;)) And I got this OAuth problem when I was trying to use audiomack API.
https://www.audiomack.com/data-api/docs
This is their API documentation. They say
Rather than manually creating code for OAuth, we recommend instead using one of the pre-built libraries available for your programming language.
And I got piles of python libraries here: https://oauth.net/1/#:~:text=Max%20Countryman%20maintains,Tornado%20Auth%20package
Because I am new to OAuth, and also do not know how to get this consumer key and secret from my audiomack account (newly created for test use), these repos give no meaning to me.
Is there anyone who can help me out? I want to know how to make a proper OAuth step to use this API.
A step-by-step guidance or relevant link will be appreciated. Thanks in advance.

Can facebook access token be used for someone else's data?

Does facebook allow to use one person's access token to fetch post info of another person (post comments, likes)?
I am thinking of implementing a pool of tokens in my app, so if token is broken I can use other persons token. Wondering if it's allowed and whether facebook have some restrictions on such a use case.
Additionally, I am currently using FQL, is there a difference for Graph API in how tokens work?
Short answer: It is not possible. That would be an incredibly large privacy problem anyway.
Also, for user postings you need the "read_stream" permission and you probably will not get this one approved:
This permission is reserved for apps that replicate the Facebook
client on platforms that don’t have a native client.
(https://developers.facebook.com/docs/facebook-login/permissions/v2.0)
About FQL: There is no difference, although keep in mind that FQL is deprecated and will be removed when support for v2.0 runs out. See this link for more information: https://developers.facebook.com/docs/apps/versions#versioning
(thanx to Tobi for clarification)

How to tweet from GAE

I want to be able to Tweet from my app running on GAE.
Please suggest some Python library or HTTP API for the purpose.
About python-twitter: I think you can use this lib it seems to be compatible with GAE: http://code.google.com/p/python-twitter/source/browse/twitter.py
Also:
Twitter has a very great REST API https://dev.twitter.com/docs/api, You can also to simply use urlfetch and simplejson from appengine.
For authentication Twitter uses OAuth and recommend to understand how it work:
Twitter supports a few authentication methods and with a range of
OAuth authentication styles you may be wondering which method you
should be using. When choosing which authentication method to use you
should understand the way that method will affect your users
experience and the way you write your application.
Twitter share a very great how to https://dev.twitter.com/docs/auth/oauth
You can also see the part of code: http://code.google.com/p/jaikuengine/source/browse/trunk/oauth_client.py from jaikuengine.
This project worked for me: https://github.com/tav/tweetapp/blob/master/standalone/twitter_oauth_handler.py
It's only one file so it's easy to get it started and uses OAuth for authentication with twitter.
I have used twython in the past. I can't remember what made me select it over other libraries but I was using it on GAE and it is kept up-to-date.
You might find the Tweet Engine project of interest. It demonstrates quite simply how to use the Twitter REST API from App Engine.

Trouble getting code parameter on facebook oauth callback

I'm writing a Django app requesting permission to post on facebook.
I can access authorization and callback, but I can't get the parameter 'code' that facebook needs to continue with oauth.
def connect_fb(request):
return redirect("https://graph.facebook.com/oauth/authorize?"
+"client_id=MY_ID&"
+"redirect_uri=MY_URL"
+"&type=user_agent&display=popup&scope=publish_stream")
def callback_facebook(request):
code=request.REQUEST.get("code")
What's the right way to get 'code' so I can continue the oauth process?
I tried several things but I keep getting None instead of a code.
Thanks
I've used django-facebook-oauth in the past, but if you really want to roll your own solution then I'd suggest just looking through their source.
From just glancing through it, the only thing I can see you doing differently is the
&type=user_agent&display=popup
in the URL. The app I linked you to doesn't appear to do that as far as I can tell.
The problem comes from type=user_agent that is used in javascript authentication, and not here.
Removing it allows to get code as above.

use python / django to let users login to my site using their google credentials

I want to let users use their google account to login to my website. Exactly the way SO lets me. Can anyone please point in the right direction? I'm assuming the oAuth library is to be used but what I'd really like is a snippet of code I can directly copy paste and get this to work.
It's not OAuth particularly that you need (OAuth is for authorising access for one website to specific private content held on another), but OpenID - which is meant for authentication rather than authorisation. (Some sites, like Twitter, do provide authentication services via OAuth, but that's not what it's primarily for.) I have used python-openid which is fairly straightforward to use, or you can look at django-openid - though it admits to being incomplete, you could get some idea of how to implement OpenID support.
The problem's a little too involved to admit a copy-and-paste solution, but it's not especially hard to do this.
Update: piquadrat's link (in he comment) is definitely worth following.
You may want to check out django-piston which is a mini-framework with oAuth built in. Here's a tutorial on how to set it up.
You might consider using Django-Socialauth, as it supports
Twitter
Gmail
Facebook
Yahoo (essentially openid)
OpenId

Categories