21057

How to change authentication endpoint to use Facebook LoginV2 URL with OWIN security

Question:

I previously asked a question about doing this in MVC4 and found my own solution.

<a href="https://stackoverflow.com/questions/24136770/how-to-use-facebook-login-v2-0-with-dotnetopenauth-oauthwebsecurity-requestauthe" rel="nofollow">How to use Facebook Login v2.0 with dotnetopenauth OAuthWebSecurity.RequestAuthentication</a>

I am upgrading my project to MVC5 so I'm moving to Facebook authentication with OWIN security rather than oAuth. In MVC4 I implemented my own Facebook client so that I could override the default authentication endpoint URL to use the V2 URL. I can't see how I can do this using app.UseFacebookAuthentication because it doesn't take a client parameter.

Facebook require all apps to use the v2 login by April so I'm really surprised that I can't find any existing questions on this. Can anybody help please?

Answer1:

To clarify the changes that Bruno suggested:-

<ol><li>Upgrade Microsoft.Owin.Security.Facebook to 3.0.1</li> <li>

In Startup.Auth.cs the call to app.UseFacebookAuthentication should be changed to look like something like this (note that this is NOT just 3 extra lines for the endpoints):-

app.UseFacebookAuthentication(new FacebookAuthenticationOptions { AppId = facebook_appId, AppSecret = facebook_appSecret, AuthorizationEndpoint = "https://www.facebook.com/v2.2/dialog/oauth", TokenEndpoint = "https://graph.facebook.com/v2.2/oauth/access_token", UserInformationEndpoint = "https://graph.facebook.com/v2.2/me" }); </li> </ol>

Answer2:

I had the same problem yesterday. Please check this working item of the katana project:

<a href="https://katanaproject.codeplex.com/workitem/363" rel="nofollow">https://katanaproject.codeplex.com/workitem/363</a>

Check this also:

<a href="https://katanaproject.codeplex.com/SourceControl/network/forks/Tratcher/Katana/contribution/7720#!/tab/changes" rel="nofollow">https://katanaproject.codeplex.com/SourceControl/network/forks/Tratcher/Katana/contribution/7720#!/tab/changes</a>

I have updated to the latest nuget pakage and this is already available. So, you can now change the authentication endpoints when creating FacebookAuthenticationOptions. This worked for me and is already in production. I had just one problem: the old application cookie was not recognised, meaning that all users will have to authenticate again.

Recommend

  • jquery date conversion chrome works but IE and firefox don't
  • PHP/mysql: how do I display records sorted by time and grouped by date?
  • PHP IntlDateFormatter wrong date/time conversion
  • declare a transaction in ejb 3.0
  • Do lifetime parameters in `*(&'a mut self)` methods confuse the BorrowChecker?
  • displaying # views on a page without hitting database all the time
  • JFreeChart BarChart - Category Markers
  • Javascript inside script tag in an Angularjs template is not executed
  • Extract decision boundary with scikit-learn linear SVM
  • How many percent of the tweets does twitter sample API give?
  • https in htaccess and order of rules (using Expression Engine)
  • UIImagePickerControllerDelegate Methods Not Called When Delegate Not UIViewController
  • Submission of new app with iAds
  • C++ accessing vector
  • jquery full calendar
  • Programatically open file in visual studio
  • Google analytics measurement protocol session timeout and query time limits
  • crash in __tcf_0
  • How to turn (A, B, C) into (AB, AC, BC) with Pig?
  • Get a trait object reference from a vector
  • apply a javascript function to draggable copy
  • LESS CSS how to modify parent property in mixin
  • Passing variable arguments using PowerShell's Start-Process cmdlet
  • Cannot get the UserManager class
  • Android changing fragment order inside FragmentPagerAdapter
  • Sequential (transactional) API calls in angular 4 with state management
  • Unable to decode certificate at client new X509Certificate2()
  • Create DicomImage from scratch using Dcmtk
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • Groovy: Unexpected token “:”
  • Date difference with leap year
  • Javascript Callbacks with Object constructor
  • Symfony2: How to get request parameter
  • ORA-29908: missing primary invocation for ancillary operator
  • Matrix multiplication with MKL
  • Acquiring multiple attributes from .xml file in c#
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?