django - Python: Check if Facebook user has granted access to my app. Fails with "HTTP Error 400: Bad Request" -


i trying determine whether user has granted access application and, if so, permissions has. not during initial sign-up process, later when need verify users hasn't removed permissions.

i run following:

access_token = "users_access_token"; # saved when user signed using fb url = "https://graph.facebook.com/v2.0/me/permissions/?access_token="+access_token response = urllib2.urlopen(url) 

if user has granted access response json string permissions. same see if copy-paste url browser.

however, if user has not granted access (ie removed app after initial sign-up) error: "http error 400: bad request". but, if copy-paste url browser json string proper error message: "the user has not authorized application..." (if enter wrong access_token in browser url still proper error message "malformed access token")

so, how can gracefully check whether user has revoked access app? don't want exception, rather proper fb error response. seems should possible since works when copy-paste url browser.

note not change code @ all. thing changes whether user has granted access app (so it's not url malformed.)

httperror contains info need, this:

try:     response = urllib2.urlopen(url) except urllib2.httperror e:     print(e.read()) 

then print out error message:

{"error":{"message":"invalid oauth access token.","type":"oauthexception","code":190}} 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -