From 0fee3c87a0359dad9df0e5a519b8b0673b8d8540 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 14 Nov 2014 15:05:31 -0800 Subject: [PATCH] #85 - Update the targeted Facebook API version to v2.2. --- samples/CookieSample/CookieSample.kproj | 5 +++-- .../CookieSessionSample/CookieSessionSample.kproj | 5 +++-- samples/SocialSample/SocialSample.kproj | 7 +++++-- samples/SocialSample/Startup.cs | 14 +++++++++----- samples/SocialSample/project.json | 5 +++-- .../FacebookAuthenticationDefaults.cs | 6 +++--- .../Facebook/FacebookMiddlewareTests.cs | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/samples/CookieSample/CookieSample.kproj b/samples/CookieSample/CookieSample.kproj index 86a746ad6c..3afd3733f3 100644 --- a/samples/CookieSample/CookieSample.kproj +++ b/samples/CookieSample/CookieSample.kproj @@ -1,8 +1,9 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + 54539 @@ -11,4 +12,4 @@ ..\..\artifacts\bin\$(MSBuildProjectName)\ - + \ No newline at end of file diff --git a/samples/CookieSessionSample/CookieSessionSample.kproj b/samples/CookieSessionSample/CookieSessionSample.kproj index 81e25a7fc4..954c473e9a 100644 --- a/samples/CookieSessionSample/CookieSessionSample.kproj +++ b/samples/CookieSessionSample/CookieSessionSample.kproj @@ -1,8 +1,9 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + 54541 @@ -11,4 +12,4 @@ ..\..\artifacts\bin\$(MSBuildProjectName)\ - + \ No newline at end of file diff --git a/samples/SocialSample/SocialSample.kproj b/samples/SocialSample/SocialSample.kproj index 358b0923ff..1fbca3ad0e 100644 --- a/samples/SocialSample/SocialSample.kproj +++ b/samples/SocialSample/SocialSample.kproj @@ -1,8 +1,11 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + 54540 + + @@ -11,4 +14,4 @@ ..\..\artifacts\bin\$(MSBuildProjectName)\ - + \ No newline at end of file diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 3ddba6fb4d..162a1b5539 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -37,6 +37,7 @@ namespace CookieSample options.LoginPath = new PathString("/login"); }); + // https://developers.facebook.com/apps/ app.UseFacebookAuthentication(options => { options.AppId = "569522623154478"; @@ -55,23 +56,25 @@ namespace CookieSample options.Scope.Add("email"); }); + // https://console.developers.google.com/project app.UseGoogleAuthentication(options => { options.ClientId = "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com"; options.ClientSecret = "n2Q-GEw9RQjzcRbU3qhfTj8f"; }); + // https://apps.twitter.com/ app.UseTwitterAuthentication(options => { options.ConsumerKey = "6XaCTaLbMqfj6ww3zvZ5g"; options.ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI"; }); - /* - The MicrosoftAccount service has restrictions that prevent the use of http://localhost:12345/ for test applications. - As such, here is how to change this sample to uses http://mssecsample.localhost.this:12345/ instead. + /* https://account.live.com/developers/applications + The MicrosoftAccount service has restrictions that prevent the use of http://localhost:54540/ for test applications. + As such, here is how to change this sample to uses http://mssecsample.localhost.this:54540/ instead. - Edit the Project.json file and replace http://localhost:12345/ with http://mssecsample.localhost.this:12345/. + Edit the Project.json file and replace http://localhost:54540/ with http://mssecsample.localhost.this:54540/. From an admin command console first enter: notepad C:\Windows\System32\drivers\etc\hosts @@ -79,7 +82,7 @@ namespace CookieSample 127.0.0.1 MsSecSample.localhost.this Then you can choose to run the app as admin (see below) or add the following ACL as admin: - netsh http add urlacl url=http://mssecsample.localhost.this:12345/ user=[domain\user] + netsh http add urlacl url=http://mssecsample.localhost.this:54540/ user=[domain\user] The sample app can then be run via: k web @@ -102,6 +105,7 @@ namespace CookieSample options.ClientSecret = "bLw2JIvf8Y1TaToipPEqxTVlOeJwCUsr"; }); + // https://github.com/settings/applications/ app.UseOAuthAuthentication("GitHub-AccessToken", options => { options.ClientId = "8c0c5a572abe8fe89588"; diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 737c6638e8..f457d3a9d4 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -11,8 +11,9 @@ "Kestrel": "1.0.0-*" }, "commands": { - "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:12345", - "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004" + /* Note all servers must use the same address and port because these are pre-registered with the various providers. */ + "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:54540", + "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:54540" }, "frameworks": { "aspnet50": { diff --git a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationDefaults.cs b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationDefaults.cs index 19cc380749..72addbef8b 100644 --- a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationDefaults.cs +++ b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationDefaults.cs @@ -7,10 +7,10 @@ namespace Microsoft.AspNet.Security.Facebook { public const string AuthenticationType = "Facebook"; - public const string AuthorizationEndpoint = "https://www.facebook.com/dialog/oauth"; + public const string AuthorizationEndpoint = "https://www.facebook.com/v2.2/dialog/oauth"; - public const string TokenEndpoint = "https://graph.facebook.com/oauth/access_token"; + public const string TokenEndpoint = "https://graph.facebook.com/v2.2/oauth/access_token"; - public const string UserInformationEndpoint = "https://graph.facebook.com/me"; + public const string UserInformationEndpoint = "https://graph.facebook.com/v2.2/me"; } } diff --git a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs index f3e0bf703b..6120b82c44 100644 --- a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs @@ -97,7 +97,7 @@ namespace Microsoft.AspNet.Security.Facebook var transaction = await SendAsync(server, "http://example.com/challenge"); transaction.Response.StatusCode.ShouldBe(HttpStatusCode.Redirect); var location = transaction.Response.Headers.Location.AbsoluteUri; - location.ShouldContain("https://www.facebook.com/dialog/oauth"); + location.ShouldContain("https://www.facebook.com/v2.2/dialog/oauth"); location.ShouldContain("response_type=code"); location.ShouldContain("client_id="); location.ShouldContain("redirect_uri=");