I'm currently writing a facebook app for windows phone, and there is something I just didn't find how to do.
Since display=touch currently doesn't work on windows phone, I am forced to use display=popup to get a token and the user's agreement for my app.
This popup mode really isn't fit for mobile apps, so I would like the user to be able to check a box saying "I would like the app to remember my login and password and connect me automatically".
However, when I have the user's login and password, I don't know how to use the OAuth API to effectively login the user without him having to click anything. Is there a way to do that ? Or do I have to wait for the user to choose "Remember me" on the Facebook login page ?
I hope that was clear enough.
Facebook doesn't have a (public) API for taking a users email address and password and returning an access token. The closest thing you can do is customize the HTML that gets returned with JavaScript. I have an example of this on my github.
Related
a c# windows application give privilege to users with a specific profile in its database. The application does not handle user and password but get the username of the authetcated user in Windows session.
They asked me to authenticate the user by a IAM service such as Microsoft IAM. But I'm a bit confused. It means that I have to ask username and password to user and verify them with IAM? I don't want to store in my db password.
I cannot figure how to use an external IAM.
No, you will not need to deal with passwords.
In short, your application will need to display a mini browser window (WebControl, WebView, etc.) where the IAM provider's login screen is displayed. Users provide their credentials directly to that login screen. Your application never touches those credentials and only receives the valid tokens afterwards from which it can get information like unique user ID, email address, etc.
Check out this WPF tutorial from one of the best IAM providers, auth0 (disclaimer: I'm not affiliated with auth0 in any way).
https://auth0.com/docs/quickstart/native/wpf-winforms/01-login
You can sign up for a free trial account to quickly try it out.
Side note: This method is not entirely safe from abuse as your malicious application could intercept key strokes as users type in their credentials into the IAM login page (since it is hosted within your application's process).
I'm working on a Windows Phone Silverlight app and I want to make a simple login via Facebook(browser). Is there a way to check if the user is logged in Facebook? I redirect the user to Facebook page with this statement:
Launcher.LaunchUriAsync(new Uri("http://www.facebook.com"));
I don't know if you are using the windows SDK for facebook
(https://github.com/Microsoft/winsdkfb) but it is a third party sdk approved by Facebook.
Before using that SDK you should set up the Facebook developer page for your app. (https://developers.facebook.com/docs/apis-and-sdks)
I hope that helps.
Here is a WPF example that uses the WebBrowser class to get a token: Facebook OAuth in WPF & C# Example
Obviously the WPF related things might differ a bit, but it should at least point you to getting the info you need out of the process. As far as checking whether the user is logged in, I pretty much just checked whether the token is valid by making some http request that uses it and seeing whether it was successful (used a REST client for that).
There was a way to directly check token validity via the Facebook APIs but that was deprecated last I checked.
I would made a very simple thing using Facebook c# sdk, but couldn't find anywhere if it's possible.
If I have username and password of a user, I could put an automatically a "like" on a specific page, without any prompt to the end user? My application doesn't have a GUI and I would made it all automatic.
I do believe it is against Facebook policy for you to collect Facebook usernames and Facebook passwords. I highly suggest you consult with your corporate attorney before proceeding.
Is there any good tutorial how to make simple console facebook appplication which connect to facebook and get list of friends, user photos, status or something. I look at facebook examples of facebook SDK but if i want to authorize on facebook i must execute FacebookService.ConnectToFacebook method which show login window. But i want show my own login window. Or just store login and password in sql server and time to time get some information about users. Is it real?
Check out the tutorial and examples here.
It should have all the functions that you need and is fairly easy to implement. Trust me, you'll spend hours going elsewhere to figure it out.
As for custom login windows I recommend that you don't do that. People trust Facebook and don't want to give you their personal info, that's actually a part of your agreement with Facebook.
What you can do however is ask for offline access permission and store the token for future use. This way if you know who the user is on your end then you can make calls to the API without having to log them into Facebook again.
Facebook requires that users login with them and Facebook will send you back a token which you can use. This is prevent applications "stealing" usernames & passwords, which you could do with your login dialog and also allows users to stop applications in future from accessing their account even if they have logged in previously.
No way round that unfortunately, unless you going to build something that doesn't use the API - for example, a tool which loads a browser in a background, and automates the login as if the user did it. That would lead to pain and suffering though.
Here's a little bit about my situation:
I want to be able to retrieve a list of emails for the friends of a given user.
Here is how I would like the process to go:
A div box pops up with a login (used to log in to their facebook account, not my website's account system - that is separate)
Then once the user has entered their facebook credentials, they will have a button appear.
Send email to all friends.
If they click on this button I would like an email sent out to all of that user's friends.
Questions:
I only want to pull out emails from a user's friends, so...
1) Is it actually a facebook app that I'm creating?
Many of the tutorials talk about facebook apps and how you have to go to facebook and create an app from there and set all of these settings for page redirects and such. I didn't think I wanted it to be an app, all I want is the information.
2) If I do need it to be an app, how is it supposed to interact with my website? Some talk about iframes, or other methods... How am I supposed to know which to use and how I can integrate it into my site?
You have to create app through facebook, but it's only for autorization information.
api key
api secret
And you have to few options for working with facebook API from C#
Facebook Developer Toolkit
.NET Facebook API Client
Facebook.NET
Bemmu is correct = you can't use facebook to get email addresses.
You can send a facebook messages (which usually sends an email to the recipient as well depending on the users preferences).
You'll need to build a facebook app, and get users to allow it to access their profile information (default request). Then you'll be able to sendNotification to receipientID's.
Start with http://wiki.developers.facebook.com/index.php/Notifications.send and look at other references to the Stream API.
Do read the guidelines and agreements - there's rules on how long you can hold onto stream data and what you can use it for.
Let me add to that the PHP API:
http://wiki.developers.facebook.com/index.php/PHP
http://developers.facebook.com/get_started.php
There are no API methods to get anyone's e-mail addresses on Facebook, and neither are there on OpenSocial. This is so that the e-mail addresses do not end up on spam lists. There is a way to send e-mail without getting to know the actual addresses though. If you get the user to accept extended privileges for your app, then you can send e-mail at some reasonable intervals to that specific user.