I'm building a site using React which logs the user in to facebook and fetches their data, which I then use to call another API. This works fine.
What I'm trying to do is then log the user out. I am not using the Facebook SDK.
I can't figure out how to get the logout redirect URL to work. I have the following piece of code which executes upon the user clicking the 'logout' button:
window.location.replace(`https://www.facebook.com/logout.php?next=https://example.com&access_token={accessToken}`
but this appears to just redirect me to the Facebook homepage, and no logging out or redirecting back to my site occurs. I can't find an example in the Graph API documentation that doesn't use the Facebook SDK.
Related
I want to publish posts on a page using Facebook API. I’m an admin of the page.
I’ve done these steps:
Created an app in dev mode
Received page access token
Made a post using Facebook Graph API
A post appeared on the page. But unfortunately no one sees it. Only me.
What am I missing? Is it because the app in dev mode? If yes, is there any way to post on a page without app review?
I don't know he oauth works in detail, but I know the overview.
So I have ionic app running in localhost (ionic serve) and a facebook created.
I have not put any callback url in advanced settings of fb app.
And I am using ngOpenFb to accomplish login with facebook.
On click of button I am calling a function which will open facebook in new window, on logging in successfully it will redirect to http://localhost:8100/oauthcallback.html.
What should be done next? Do i need to specify some redirect in oauthcallback.html?
Please help..
I am trying to register users via Facebook using django rest-auth.
As per the installation docs here, a rest call to register a user via facebook requires an "access token" and "code". I know what an access token is, but what is "code"?
First of all, you need to create a Facebook Application in the developers page. You will get a Facebook app code and a secret.
For using the /rest-auth/facebook/ method from the django-rest-auth, you need to send the access code (obtained using the javascript SDK) and the code of the Facebook Application.
Finally, before using this method, you have to go the the application back-office and create a social application, using the Facebook app code and the secret.
I wonder what is the right technique to streamline the login to my site via Facebook.
Currently, I have a web site integrated with Facebook Login button. Right now, it's an independent web site, and not a "Facebook app" (running in the canvas). While this is not my decision, this could change in long term if matters.
The way the authentication work: the "fb-login-button" is redirected to my application URL using onlogin() event; the server side uses the cookie to retrieve the "access token" and perform further Graph API work. The business logic resides on the server side.
The current business requirement is the following:
Suppose someone posts a link to my site, somewhere in Facebook, for example in our site community page:
http://www.mysitedomain.com/offer1
A Facebook logged-in user clicking on the link - should get to the target page, after his Facebook identify got verified, and the result should be personalized for that user.
If a Facebook user already has an active session with my site - trivial.
Assuming a user had approved my site (app) in the past, but has no active session - here I am looking for the best practice to do the login.
Also, I would appreciate a hint how to handle the app authorization (i.e. showing the Facebook authorization dialog) in a most efficient way.
Thanks for any hint.
Check out FB Login Architecture and FB.getLoginStatus. Based on FB documentation, If you use javascript sdk, it only triggers a Popup on the same page and once authenticated it will go back to the same page. So once the login status is confirmed then you can get users information from graph api and update via AJAX on your page. You can also checkout this server side login. Hope this helps.
I'm integrating Facebook into my application. A user in my app can either be authenticated via Facebook, or be authenticated by their account (email address + password) with the app. I have a page in my app where I pull Facebook friends list using FB Javascript sdk. I log into the app using Facebook authentication then navigate to the page and can see my friends list. I can then logout of app using FB.logout then login to the app using a different user account (email + password) then navigate to the page and still see my friends list. I've logged into the app using a non-facebook authenticated login. It's not a caching issue as I have no caching set up in my dev environment. I'm new to Facebook. Any ideas on why the friends page is still retrieving friends list? Thank you!
I doubt the browser is caching the friend list, unless your loading the friends list after the page is loaded via ajax. But even then it would be rare to see such a thing.
I've never used the js sdk. But i know with the PHP one it automatically stores the fb token in the session. However ive just had a thought, if your using the JS SDK, that probably means that your not using tokens like the PHP sdk does. I would guess that its because facebook is detecting the user as logged in ?
Try logging out of facebook after you logout of your own site, then login with a different account. If that works, then you need to google around and get the code for logging them out of facebook. I believe the old trick was to just header redirect them to the facebook logout url, but there may be a nicer way of doing this.
Having said that, this would log them out of facebook, so you might annoy some people. How often can you see people logging out to log in with a different account?