Web API FB OAuth? How would to go about implementing it in a SPA application? - facebook

Documentation on the net seems to be VERY scarce. The only option I can think of at the moment
is to have my SPA app break convention and to have the (initial) logged out page be different to the logged in one (eg my app).
My app is built using Durandal 2.0.0.
In one of my OAuth tests app's I've managed to implement this link successfully. But as Durandal does not work in the same way (Server-side controller, & razor views), I'm thoroughly confused in how to achieve what I want to.
I'd like to have my app remain a single page app. But I've got little to no experience with the OAuth SDK
My only requirement is that the user log into my app using his FB account.
I've had an initial stab at this using the FB java script API, and got it working, but after discussions with another developer this side, it doesn't seem like the purpose of the java script API is to facilitate secure application login's? As the way we had it, would allow any user to pass a valid fb userId, then he would be logged into our app. :/
How would I go about achieving this process flow in a Durandal/Web API Single Page App?
User logs in using fb ->
then on the server we get his fb userId ->
retrieve our internal appID
I'm not asking for a complete answer/for someone to do my work....
But any documentation to get me started/less confused would be greatly appreciated.

Here is a sample project which demonstrates how to use OAuth with Durandal and Web API:
DurandalAuth.
However there are some modifications in viewmodels needed, since router changed in Durandal 2.0.0.

Related

Ionic App, silent Authentication or refresh token to allow user stay signed in

I just created a new Ionic app and using Auth0 for user login and registrations. I have .net core backend.
I am following the Ionic quick start guide https://auth0.com/docs/quickstart/native/ionic4/01-login and everything is working ok. I use new Universal login.
The issue I have is users get logged out after the access_token has expired. I previously used Silent Authentication and refresh tokens in two different apps, however I am unable to find a sample code like quick start guide for either. I have an angular website too. Hence my users can either use mobile app or Angular website to login. I would appreciate any help to keep my users loggedin, in both website and ionic mobile app please.
Many thanks
Last I checked, Auth0 doesn't have many samples for acquiring refresh tokens from application frontends, which is typically what I would consider ionic/angular to be used for. Obviously, you could be building a "native" style application with either of those, but frontend auth is sometimes a little messy and insecure because the client has your code and you usually need to implement some kind of middleware.
It looks like the ionic quickstart uses auth0-js which defaults to an implicit flow, which would confirm my hunch above.
I personally pass the refresh token logic off to my backend, and let the backend function as my "middleware". You can find some basic code samples for backends/native apps here. I use the code-grant flow typically, but you could use PKCS.
The long and short is, I don't think you're going to find sample code on that, but you could hack something together with something like axios if you wanted to go the middleware route, or you could go backend with your auth.

Can I include Facebook login/API calls *without* hosting my web application online?

I'm having some trouble understanding the steps I need to take in order to make basic requests to the Facebook API. I've been reading the documentation, and having a play with the Graph Explorer, however I'm a little confused getting started.
I'm making a game application for a University submission, for which Facebook integration is a small but important part. I will be submitting this application on disk, and it will need to work when the HTML page is launched from this disk - this is where I'm getting a little stuck. I'm not sure if I'm overthinking this, but I seem to need to register as a Facebook Developer and set up an application domain. Is this necessary? I won't be able to host this application online, it will have to be submitted on disk.
So, my questions are -
Is it possible to include basic Facebook integration without hosting the application online? (Login, retrieval of a list of the user's friend's ids)
(If this is possible) what do I need to do to handle the basic 'setup' of Facebook integration? I've been looking at the Javascript SDK reference and I see I need to have my appId and channelUrl for the Loading and Initialization. I see the appId quite clearly in the App Dashboard, however it is the channelURL I am having trouble with.
I hope that makes sense :) Loading and initializing the framework and then making Graph API calls seems pretty straightforward - I'm just not sure if it's possible without hosting the application online.
Cheers!
Your page should at least be reachable via HTTP – so put a portable webserver (could be a portable Apache distribution, or something smaller) on your “disk” as well, and run your app using http://localhost/…. Add that same address (protocol and domain only, no path) in your app settings for “Website with Facebook login”.
And for the channelUrl, see https://developers.facebook.com/blog/post/2011/08/02/how-to--optimize-social-plugin-performance/

Intranet Facebook Application for updating status

I'm writing an in house intranet application which needs to update our Facebook status. (I'm new to FB development so please go easy) I don't want this application to be visible to anyone - the updates will occur via a call to the API (using the FB C# sdk) - I'm currently running in dev/sandbox mode and it's all working but is there a simpler way i can update FB status' without having to create an app in FB and authenticate etc. with OAuth? This has to be done via a web application as we have an internal review process that needs to take place on the status content then posted via an app when someone who knows the Facebook access details logs in via the app itself.
Many thanks.
Sounds like you're already doing it the best/only way which will work for that use-case

Creating Facebook App

Im new to facebook applications. I recently created a webapp that consisted of html & php. But recently Ive decided that integrating my webapp within facebook would be useful. Any tips on where to start? Ive looked over developers.facebook.com and im confused. It appears they are in the process of updating. Ive come across a few guides but there from a few years ago. This app will run completely within facebook and im probably gonna have to rewrite all the code. Any guides or suggestions?
Thanks!
You didn't specify the programming language you're using but if you're developing asp, start by looking into Facebook c# sdk here: http://facebooksdk.codeplex.com/
If you're using any other language (i.e. php), try looking into respective software dev. kits (i.e. facebook php sdk). They will facilitate your job in comparison to starting raw development all by yourself.
Tim, if you want to get into the business of working with Facebook, you need to know right away that they are always in the process of updating. That being said, you should learn some Facebook terminology so you can do more research and figure out what you want to do.
Applications that run within the Facebook interface are called Canvas Apps. Your application is hosted on your own server, and Facebook simply adds an iframe in their UI that points to your app's URL.
Another way to go to create a webapp that uses your own design, but still utilizes a single sign-on system from Facebook. This used to be called a Connect App but now they don't really have a name for it. Basically, you can use Facebook's authorization system to pull Facebook user data into your own database, which basically eliminates the need for a registration page. The authorization system prompts the user to allow your app to get specific data about them - once they authorize it, your app has access to do whatever the user gave it permission to do.
The best document to wrap your brain around is about authentication: http://developers.facebook.com/docs/authentication/
Give that a whirl, and good luck!

How to get facebook data from app?

I'm writing a sort of visualization desktop (non-web) application, just for fun.
However, ideally I'd want it to be able to pull information from the user's facebook account. (after getting its credentials, of course)
What's the best way to do this? Should I register a new 'facebook app' even though I'm not really making it web-based? I've never written a facebook app before.
I'm using Java as my prog language, btw.
Thanks!
Yes. Facebook supports desktop applications, but they must go through a special authentication mechanism. Essentially, the user will need to be directed to facebook through a web browser window as part of the authentication process.
Here is the documentation on the authentication process: http://wiki.developers.facebook.com/index.php/Login_Desktop_App
There is a relatively polished Java library for facebook here: http://code.google.com/p/facebook-java-api/
If the Java library above does not meets your needs, you can build an implementation on your own. Essentially, you will need to interact with the Facebook REST server, as described at the top of the page here: http://wiki.developers.facebook.com/index.php/API
Edit: After doing some more research I have a few more resources to provide:
Here is a list of some applications written using Java for facebook:
http://wiki.developers.facebook.com/index.php/Facebook_apps_written_in_Java
And there's even a neat desktop application that is open source here:
http://code.google.com/p/fb-photo-uploader/
Good luck!