I have an ASP.NET MVC Site in which I would like to allow my users to grant access for my app to post to their facebook account.
My site already has log-in and auth set up, so I do not currently wish to use FB for auth/account creation.
I suppose I would like something like twitter provides, to allow users to grant access to their fb account.
Are there any samples of how to accomplish this? I am not having much luck with the docs
I'm right now building exactly the same thing!
Use the http://facebooksdk.codeplex.com/ - Facebook C# SDK.
In MVC you can add it with NUGET (search for FACEBOOK - MVC) by NTotten.
Once you added it, use the tutorial from codeplex to integrate Facebook authentication for your app.
THEN in your user database add a custom field - and link the facebook userID to the regular user ID.
The same way, e.g. stackoverflow.com has done it.
Seperate user accounts from real authentication.
YOUR site manages the user accounts, authentication is managed seperately(e.g. facebook, live-id, openid, your own id).
Makes sense?
Related
We have an application designed 3 years back in ASP.Net & SQL Server 2008.
We designed our own login DB design and forms authentication for the application with the help of ApplicationUser, Role, Then other transaction tables using UserId for getting the corresponding user records, history records.
So far no issues with new user registration and bringing and managing existing user records.
Now our client wants to integrate, Google Account Login for the new customer
and even the existing customer can sign in with the Google account.
We are wondering how it is possible. If you use Google Account to login, how we manage UserId mapping and other tables.
Is it possible to integrate the Google Account Login with the existing Application has designed with its own login implementation?
If yes, what are the things to be followed/considered for implementing this?
Another suggestion might be to use the nuget package SimpleAuthentication.**
Out of the box, it has an MVC controller which means all you need to do is implement the code for checking if the user exists in your system, etc. (ie. when you come back to your website from Google).
If you're on webforms (appologies) then you need to do a bit more work by creating your own form call back and then handling the return from Google.
** Disclosure: I'm one of the 2 main contributors for it.
I would use Windows Identity Foundation. It uses claims based authentication so all a user needs to access your site is a security token with a claim. You could set up a separate Security Token Service that authenticates users based on your own database and users could also retrieve tokens by logging in through Google or with any other party you configure your app to trust.
Ages ago I've created small ASP. NET MVC and if I remember correctly you can find the solution described here and here.
You may be able to find your answer in this Google+ document regarding adding Google+ authentication to existing Facebook implementations:
Adding Google+ to your Facebook Integration: Storing authorization
It talks about migrating from a single User table to a User and Identity table.
You could implement something like this in two ways:
Keep the username/password/email fields on the User table, and attach a Google authentication provider in the Identity table only when necessary.
Include username and password fields on the Identity table which are checked if the provider is "local".
You could use DotNetOpenAuth for that.
This is a "library that adds support for your site visitors to login with their OpenIDs by just dropping an ASP.NET control onto your page. It's that easy. An AJAX-style OpenID Selector control is also included for a slick, streamlined user experience."
This post explains how to work with it for Google account.
Is it possible to programmatically sign in to my Google account through my web site in c#?
Just as a user would do manually by entering their email and password here:
https://accounts.google.com/ServiceLogin
By this I mean, on page load, the code would check to see if the user is logged in, and if not, then log them in.
I would really appreciate any help anyone has.
Google uses OAuth for authentication. You need to include an oauth client in your application in order for the user to login to their google account. There are many oauth packages for .NET, i use DotNet OpenAuth
related:
OAuth C# Library for Google, Yahoo! Twitter
I'd like to do the following:
Allow users to register in my asp.net site using their facebook credentials.
Retrieve facebook client information. Like (Name, surname, email address etc). So I can import this information into my application.
Allow users to log into my site using facebook credentials.
I've been searching and have come across these options:
Facebook.net SDK
dotnetoauth
Facebook Connect
Graph API
I'm confused as to which would be the best way to go about this.
I think that this resource offers a good tutorial on how to integrate with Facebook's user infrastructure:
http://devtacular.com/articles/bkonrad/how-to-retrieve-user-data-from-facebook-connect-in-aspnet/
There is also this code example / framework which takes you though much of the process:
http://fbconnectauth.codeplex.com/
And this walkthrough which is a little more up-to-date:
http://area72.ro/general-it/how-to-login-via-facebook-in-asp-net.html
The easiest way to implement your solution would be to use the javascript SDK for this.
You add a Facebook Login button which the user clicks on and authorizes your website giving you access to his information. This basically skips the need for registration for facebook users since the registration is the actual login process.
When the user has authorized your website (thus logged in and registered) you have access to his information which you can use to store in your users database using his faceboook id as a key. You can access the user's information sending an http request to the graph api https://graph.facebook.com/facebook_id which will return a json object with the users information.
Other then the facebook login you will want a standard login, registration form for users without facebook.
http://developers.facebook.com/docs/guides/web/
I'm just about to start a new ASP.NET project using MVC3, and since some of the requirements are about facebook integration, I need your advice on the following issues:
1- Is it achievable to connect my Membership users to thier Facebook accounts so whenever a user share/add/comment on an event on my website, I can automatically share these actions using his/her Facebook account?
2- also the ability to create Facebook events when the user create one on my site, and if he/she updates the event information, I may update them on Facebook too.
3- Can this be achieved using Facebook Connect, or this is only to authenticate users using their Facebook accounts?
4- How about using Graph API from my MVC solution, I know that there is a Facebook C# SDK on Codeplex http://facebooksdk.codeplex.com, but will it satisfy my mentioned needs or not.
Thanks in advance.
I've done something similar recently. Based on my experience:
Yes, you can connect your membership with a Facebook account, however it does not guarantee your user activity will be pushed to Facebook. (users have to log in with Facebook authentication)
Same as above. This blog post does a good job of describing it: http://amirrajan.net/Blog/asp-mvc-and-facebook-single-sign-on
No, facebook connect only takes care of authentication. For more information, check: http://thinkdiff.net/facebook/graph-api-javascript-base-facebook-connect-tutorial/
I have not tried the Facebook SDK you mentioned. However, I believe facebook Graph API already does a good job for you to and will fulfil your requirement
I am totally lost finding the right API to create a sign up process like Foursquare. I am attaching a document of what I am trying to do. I have already tried OAuth, JavascriptSDK, Facebook.NET API from Codeplex and FacebookToolkit.NET from Microsoft. Nothing looks what I actually need. I think some one experienced can lean me towards where I should go straight.
https://docs.google.com/fileview?id=0B6mlBkccI34zNDNmMGMyNTYtMDY2NS00NmEwLTlkMjQtZjA5NmVmZDMzYzlj&hl=en&authkey=CNPH9LEL
Note: I am trying to achieve this via ASP.NET with C#.
Facebook Graph Api is the best.The url is http://developers.facebook.com/docs/api
The Graph API uses OAuth 2.0 for authorization. Check out the authentication guide for the details of Facebook's OAuth 2.0 implementation.
OAuth 2.0 is a simpler version of OAuth that leverages SSL for API communication instead of relying on complex URL signature schemes and token exchanges. At a high level, using OAuth 2.0 entails getting an access token for a Facebook user via a redirect to Facebook. After you obtain the access token for a user, you can perform authorized requests on behalf of that user by including the access token in your Graph API requests:
https://graph.facebook.com/220439?access_token=...
Check out the PHP example code or the Python example code on GitHub to see a complete example of obtaining an access token for the current user. The steps to obtain an access token are:
Register your application to get an app ID and secret. Your Facebook app ID is your client_id and your Facebook application secret is your client_secret.
Redirect the user to https://graph.facebook.com/oauth/authorize with your client_id and the redirect_uri. The redirect_uri parameter needs to begin with your app's URL. For instance, if your URL is http://www.example.com then your redirect URI could be http://www.example.com/oauth_redirect.
https://graph.facebook.com/oauth/authorize?
client_id=...&
redirect_uri=http://www.example.com/oauth_redirect
After the user authorizes your application, we redirect the user back to the redirect URI you specified with a verification string in the argument code, which can be exchanged for an oauth access token. Exchange it for an access token by fetching https://graph.facebook.com/oauth/access_token. Pass the exact same redirect_uri as in the previous step:
https://graph.facebook.com/oauth/access_token?
client_id=...&
redirect_uri=http://www.example.com/oauth_redirect&
client_secret=...&
code=...
Use the access token returned by the request above to make requests on behalf of the user:
https://graph.facebook.com/me?access_token=...
You are looking for the Facebook Connect API.
More info for the single login process can be found here
You could also leverage OpenID
Your document notes the Yelp signup process, which is very low friction and allows the user's information to be available to the website without having to go through Facebook's authentication process.
Yelp, Microsoft Docs, and Pandora are using a feature of Facebook called Instant Personalization. Instant Personalization is not available to developers as of yet and is only available to those three partners.
That being said, you likely would need to use the Facebook Login Button to allow the user to grant you access to their information (including their friends list).
As far as the process of getting a list of friends, use the graph call "me/friends"
I manage FaceSharp, a .NET open source project to help people get started with Facebook Development and will be adding functionality similar to what you are looking to do in the future, perhaps some of that code will help you in your efforts. It's under the MIT license, so take whatever you want.