How to use Facebook login on the universal Windows platform?

Asked

Viewed 89 times

2

I’m trying to build Facebook login into an app so it works using the app or website according to the tutorial:

http://facebooksdk.net/docs/windows/config/

There is a similar question, but that does not suit me for limiting the solution only to the application for what I understood: Using Facebook Login on Windows Phone 8.1 1

I just added the xml file with my application id on Facebook. I also added the protocol and put this code in my main code:

        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            // You can setup a event handler to be called back when the authentication has finished
            Session.OnFacebookAuthenticationFinished += OnFacebookAuthenticationFinished;

            var protocolArgs = args as ProtocolActivatedEventArgs;
            LifecycleHelper.FacebookAuthenticationReceived(protocolArgs);
        }

        private void OnFacebookAuthenticationFinished(AccessTokenData session)
        {
            // here the authentication succeeded callback will be received.
            // put your login logic here
        }

However, trying to add Facebook.client didn’t succeed and probably why, the above functions are not being recognized so I can override.

Does anyone know what may be missing? How to complete this goal?

1 answer

1

In the question it was not clear which tool is using for communication with Facebook, so I will deduce that you are using facebook-csharp-sdk. Another interesting option is Facebook Service - Uwpcommunitytoolkit

Api and configuration of applications that interact with facebook constantly change, at present date so that an application uwp can use facebook login some settings are required:

  1. Register as a developer on the page https://developers.facebook.com/apps
  2. Add an app
  3. Download the source here (to generate the SID required by the facebook app)
  4. In the guide Configurações - Básico

inserir a descrição da imagem aqui

The only information entered will be Nome da Aplicação, Email de contato, SID da Windows Store (veja como pegar o SID para debug no código fonte disponível no final da resposta)

  1. Clicking +Adicionar plataforma and choice Aplicativo Windows informed the SID da Windows Store (pode ser gerado SID para teste, veja como no fonte no final da resposta)
  2. In the option PRODUTOS choosing Login do facebook and configure as image:

inserir a descrição da imagem aqui


After the app created and added settings, add the Id do aplicativogenerated by facebook in the application.

//somente para teste não informe diretamente no app em produção
private const string AppId = "XXXXXXXXXXXXX";

Done this, your application will already be able to use facebook as login tool (tested with facebook api version v2.8).

inserir a descrição da imagem aqui

Source Code: https://github.com/rubgithub/FacebookLogin-UWP

References:
https://github.com/facebook-csharp-sdk/facebook-csharp-sdk http://docs.uwpcommunitytoolkit.com/en/master/services/Facebook/ https://stackoverflow.com/questions/33098187/facebook-login-windows-10-uwp-desktop http://dotnetbyexample.blogspot.com.br/2015/06/custom-oauth-login-to-facebook-for.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.