简体   繁体   中英

Xamarin Forms facebook Login Xamarin.Auth

I'm new to Xamarin forms and I'd like to build an application with a Facebook login button and Xamarin.Auth. I found a lot of stuff online but I can't find a way to make it work. Maybe because I found some old implementations or because of my project configuration i'm not really sure what's wrong with it.

I'm working on a MacBookPro so I use Xamarin Studio for Mac and I want to build this application for Android and iOS first but it might be extended later to Windows phone.

Here are the versions I use:

  • Xamarin Studio Community Version: 6.1.1 (build 15)
  • NuGet Version: 3.4.3.0
  • Xamarin.Android Version: 7.0.1.2 (Xamarin Studio Community)
  • Apple Developer Tools: Xcode 8.0 (11246) Build 8A218a
  • Xamarin.Mac Version: 2.10.0.103 (Xamarin Studio Community)
  • Xamarin.iOS Version: 10.0.1.8 (Xamarin Studio Community)
  • Operating System: Mac OS X 10.11.6

I tried the following example but I couldn't find a way to make it working:

https://components.xamarin.com/gettingstarted/xamarin.auth

As I am a novice with Xamarin.Forms and more globally with Mobile Application development I have no clue where to put the Code they provide.

So I tried to put the OAuth2Authenticator in my LoginPage together with the auth.Completed event so when the user is authenticated I can save the Account data a show my MainPage

I tried to run the app like that, it doesn't trigger any errors. I then tried to display the facebook button on the page with

auth.GetUI ()

But it gives me the following error message:

'OAuth2Authenticator' does not contain a definition for 'GetUI' and no extension method 'GetUI' accepting a first argument of type 'OAuth2Authenticator' could not be found (are you missing a using directive or an assembly reference?)

I feel like it's almost working but I can't get the Facebook button. How can I display it?

see this link:

http://www.codeproject.com/Tips/852742/Simple-Twitter-client-using-Xamarin-Forms-Xamarin

just change following code :

                var auth = new OAuth2Authenticator(
                               clientId: "your facebook clientId",
                               scope: "email",
                               authorizeUrl: new Uri("https://www.facebook.com/dialog/oauth/"),
                               redirectUrl: new Uri("https://www.google.com/")
                           );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM