Facebook status update using django - python

I have used python-social-auth for social authentication in my django application. Now I am going to post facebook status from this application.
At first I have created a facebook app from https://developers.facebook.com/. Here are the steps I have followed ,
Create new app
Display name and namespace is given. Category selected as Games then create app.
App settings -> Add platform -> Website -> site url = test1.com:8000 -> save changes.
I have also made the application and all its live features available to the general public.
Then I have added ,
SOCIAL_AUTH_FACEBOOK_KEY='****************'
SOCIAL_AUTH_FACEBOOK_SECRET='**************************'
and
SOCIAL_AUTH_FACEBOOK_SCOPE = [
'publish_actions'
]
to settings.py .
When I run this app and start with facebook authentication it displays following popup,
And when I click on Play now button it successfully redirects to my django app's homepage and post my facebook status,
Here is my code for posting facebook status ,
social_user = request.user.social_auth.filter( provider='facebook',)[0]
graph = facebook.GraphAPI(social_user.extra_data['access_token'])
graph.put_object("me", "feed", message="here is status messgae")
But when another user [other than my facebook account] tries to authenticate this app is displaying popup like this ,
In first case I have successfully posted my status, But In second case I am [ message in second popup clearly shows that the app doesn't have any access to users wall.]
This is the error I am getting for the second case ,
GraphAPIError at /
(#200) The user hasn't authorized the application to perform this action.
My question is that , Why my app is not able to post on others wall ?
Is there is any bad configuration (or missed something) I did while creating facebook app ?
Or something else I have to add in settings.py.

The app settings are just fine. Actually, facebook recently made some significant changes and introduced v2.0 (learn more about this here)
So from now on (you can even check the warning in the first dialog)-
If your app asks for more than than public_profile, email and user_friends it will require review by Facebook before your app can be used by people other than the app's developers.
Only the testers/developers of the app can test the app with other permissions before they are reviewed by facebook.
You can check out the review documentation for more details.

Related

If the user visits my flask website from his/her email; how can I get his/her email address?

If the user has a mail message containing a link to my webapp which is built in flask. The user clicks the link and visits my site.
The question now: how can I configure my flask app to detect that this user has visited the site via email?
You can configure the URL as a campaign. So for example:
https://www.example.com/?utm_source=newsletter&utm_medium=email
You can build the link here: https://ga-dev-tools.appspot.com/campaign-url-builder/
Then in your app, you can get the utm_source and utm_medium like so:
from flask import request
source = request.args.get('utm_source')
medium = request.args.get('utm_medium')
It also works with Google Analytics if you have G Analytics installed.

Django : How can I fix this when adding facebook login to django app using social-auth?

I am using django to create a web app and add facebook login in the homepage. But whenever I run click on the facebook login link, I get the following error. Can anyone tell me where the error is and how I can fix it ?
Go to facebook developers.
Select your app.
On the left menu choodse Facebook login -> Settings.
In the "Valid OAuth redirect URI's" enter the proper URL.
It your site is https://example.com and you registerd all_auth app url's under /accounts the default callback URL should look like this:
https://example.com/accounts/facebook/login/callback/

Python Social Auth - Facebook Auth API v2.5

I'm using python-social-auth. On June I've created the app on developers.facebook.com. Facebook's api version is v2.2. Everything is working.
Additionally my user model using email as username so I defined in settings.py SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'].
Today I've created new app on developers.facebook.com, api version is v2.5. Configuration of app is the same like in my v2.2 app. There is a problem. After redirect from facebook.com, Im using create_user() to create user. I don't know why I've know user data (email, gender, etc) I've only UID, first name and second name.
Of course Im testing social authentication in one www project.
It may be the fault of Facebook App Update?

Python-social-auth: Redirect uri mismatch on Soundcloud login

I'm having trouble associating Soundcloud accounts to user accounts on my app.
The app is built on django using python-social-auth, and I also have a Facebook association, which is working perfectly.
When I click on the soundcloud button, it redirects me to
http://local.gl.com:8080/?error=redirect_uri_mismatch&error_description=The+redirection+URI+provided+does+not+match+a+pre-registered+value.&state=OBclf3I3ODoKKD5uRdD97AozInK1iUF2#
and nothing happens.
local.gl.com is mapped to my development server address on /etc/hosts
my redirection URI on the soundcloud developers page is
http://local.gl.com:8080/ and on my settings.py I have:
SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/users/register/'
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
On the .html file I have
soundcloud
Which is basically the same thing I'm using for Facebook, which is working.
I've tried everything that I could find on SO, including registering a new app with soundcloud but I always get the same error.
Any suggestions?
I just had to change the redirect URI on soundcloud page to
http://local.gl.com:8080/complete/soundcloud/
I had already tried that but I had a different error on the settings.py that I hadn't realised, so I was also getting an error with that uri

How to tweet / post a Facebook status from Django?

I would like to have the option for a registered user to tweet/post a FB status from Django app.
I'm using python-social-auth with Facebook/Twitter enabled.
How can I add such functionality to all registered users? (for those who signed up using their FB/Twitter account and for those who didn't)
Thanks

Categories