I know that a 'Name' field is provided, but I would prefer to access the first and last names explicitly. Can someone help with this? I'm still wrapping my head around ASP.Net MVC.
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- facebook error invalid key hash for some devices
- LoginActivty with Firebase & Facebook authenticati
- Register MicroServices in Azure Active Directory (
- parameters in routing do not work MVC 3
相关文章
- 在DotNetFx Owin 环境下调用 opencc.dll 报错
- Facebook login for group members
- Why do I need a ToList() to avoid disposed context
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
Facebook changed its permission api. You can get more information about it here: https://developers.facebook.com/docs/facebook-login/permissions
Name need public_profile permission
And you can get it using:
authenticationManager is an instance, you can get using:
In your Startup.Auth.cs
ConfigureAuth(IAppBuilder app)
method, set the following for Facebook:Then use this to access the user's login info:
And then the following to get the first name:
Unfortunately this method doesn't work anymore since Facebook changed their default return values with API update 2.4
It looks like the only way to get the first_name etc. now is to use the Facebook Graph API (like this posts suggests).
I also found this post on the Katana project site that addresses this issue and already submitted a pull request but it has not been merged jet.
Hopefully this safes somebody a little bit of time ;)
Facebook has changed the way their Graph API returns value in upgrade 2.4. Now you need to explicitly specify all the fields that you want to get back.
See this note from: facebook for developers Upgrade Info:
To get Email, FirstName and LastName from facebook:
First, you need to install Facebook SDK for .NET nuget package
Then, in your startup.Auth.cs, change the configuration of Facebook Authentication as follow:
Finally, in your AccountController, add the following code to ExternalLoginCallback method:
See facebook API Guid for more parameters that you can get back.
Add firstname and last name in facebook option Scope