Facebook Login for Windows Phone 8.1

I am trying to figure out a simple facebook login code from a Windows Phone 8.1 (C #) application.

Since NuGet's Facebook Client not targeting Windows Phone 8.1, it seems I need to write additional code. When I read facebook in this post , I need to run Uri to bring up the Login dialog. So much I have succeeded:

  await Launcher.LaunchUriAsync(FacebookUri.DisplayLoginDialog); 

where DisplayLoginDialog is a static string object with the required data on demand (appId, productId, permissions, etc.). I was redirected to the facebook application to accept that my application requires such permissions.

And I agreed.

So now? How to get an answer or something with access_token ? I researched a lot for this, but I could not find the relevant posts.

The same facebook link on top says in the Processing section of the login dialog , which:

<i> If someone successfully logs in, the URI of your application will be automatically activated, that is, they will be sent to your application along with the access token:

 msft-{ProductID}://authorize/? access_token={user-access-token}& expires_in={expiration-time-of-token} 

But I am confused about how to actually use this in C #.

How can I get an answer with access token after you logged in, or an error code and error message if it worked, for example, it is written in a message on facebook?

+6
source share
3 answers

In the Package.appxmanifest file, go to the "Ads" tab and add the Protocol Declaration.

In the Name box, enter your Microsoft product identifier as "msft-PRODUCT_ID" [product identifier without a dash].

In the App.xaml.cs file, add the following code

  protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; Uri responseUri = eventArgs.Uri; //Now you can use responseUri to retrieve the access token and expiration time of token } base.OnActivated(args); } 
+5
source

Check it out, WindowsPhone Store 8.1: Example integration with FaceBook (C # -Xaml)

+2
source

Perhaps you should take a look at this: Log in to your Windows Phone 8 application using Facebook.

In this Microsoft blog tutorial, you'll learn how you can directly link a Facebook application to your application, as many Android and iOS do.

0
source

Source: https://habr.com/ru/post/973451/


All Articles