93 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 11
4 star 21
3 star 30
2 star 17
1 star 14
Compatible with
  • iOS
  • Android

Xamarin.Auth 1.2.3.1

Xamarin

A cross-platform API for authenticating users and storing their accounts.

Xamarin.Auth helps you authenticate users via standard authentication mechanisms (e.g. OAuth 1.0 and 2.0), and store user credentials. It's also straightforward to add support for non-standard authentication schemes. The library is cross-platform, so once you learn it on iOS, you're all set on Android.

using Xamarin.Auth;

var auth = new OAuth2Authenticator (
    clientId: "App ID from https://developers.facebook.com/apps",
    scope: "",
    authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
    redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));

auth.Completed += (sender, eventArgs) => {
    DismissViewController (true, null);
    if (eventArgs.IsAuthenticated) {
        // Use eventArgs.Account to do wonderful things
    }
}

PresentViewController (auth.GetUI (), true, null);

It's that easy to authenticate users!

Some screenshots assembled with PlaceIt.

Release Notes

Release v1.2.3.1

  • Updated support for Xamarin.iOS Unified API

Release v1.2.3

  • Adding support for Xamarin.iOS Unified API

Release v1.2.2

Fixes:

  • AccountStore now properly deletes accounts on Android.
  • iOS activity spinner is no longer white on a white background in iOS 7.
Write a Review

47 reviews

IZI LABS rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Hi, on linkedin (in iOS) I am getting a warning popup: "Authentication Error e.Message=Error authenticating: Invalid_Request" after getting the user info!

Everything went well and I got the user information but it displays that popup! And the bolean ShowErrors setted to false it's not working on iOS.

Another problem is, for example, on Google, when user denied the permission... An popup with information "acess_denied" is showing multiple times! This occurs because the event Error is fired multiple times!

I think it is doing multiple requests!

Posted on: April 21 / Version: 1.2.3.1
Vishal Kathiriya

I am getting Google Auth Error:disallowed_useragent in Android when I try to authenticate google login using Xamarin.Auth. Google Document says Google has changed its Oauth policies, with this it is intended that no native web views initiate Oauth flows. Are there any plan to release new update supporting Google's Oauth requirement ?

Posted on: April 18 / Version: 1.2.3.1
Marcos Rodrigues rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I tried the above Sample under a iOS unified project. However, I hit an error at this line: "UIViewController vc = auth.GetUI (); " after clicked on the Login button from the main screen.

error message: System.MissingMemberException. Method not found for: 'UIKit.UIWebView.set_Delegate'.

Posted on: March 14 / Version: 1.2.3.1
Dhruv Gohil

I am getting Google Auth Error:disallowed_useragent in iOS when I try to authenticate google login using xamarin.auth.Google Document says Google has changed its Oauth policies, with this it is intended that no native web views initiate Oauth flows.Are there any plan to release new update supporting Google's Oauth requirement ?

Posted on: January 16 / Version: 1.2.3.1
Greg Moyer

I don't see support for the resource (identifier associated with a Relying Party Trust) parameter, which is a required parameter for my authorization Url. Unless I am missing this, I can't use this as is.

Posted on: November 22, 2016 / Version: 1.2.3.1
michael mcdonogh

this stopped working after November 1 2016 for google. check this out: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html

when can we expect update to component

Posted on: November 10, 2016 / Version: 1.2.3.1
User31 Development

Is Account Store accessible when app is in the background

Posted on: October 10, 2016 / Version: 1.2.3.1
Paul Freedman

@Diego - not sure if you found a solution to your keychain error in ios10 but this stackoverflow answer fixed it for me - http://stackoverflow.com/a/39576798

Posted on: September 21, 2016 / Version: 1.2.3.1
Diego Banovaz

Always worked fine, now, going to iOS 10 I get error while storing my account. "Could not save account to KeyChain: -34018"

Posted on: September 14, 2016 / Version: 1.2.3.1
james gabriel rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

trouble: redirect url not encoding properly.

http://sample.com encodes as http:%2F%2Fsample.com which should be http%3A%2F%2Fsample.com

Posted on: June 26, 2016 / Version: 1.2.3.1
Varfolomeev Ilya rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

trouble: present auth.getui(), dismiss, then present and dismiss - dismiss not working (iOS), this problem in HasComplete

Posted on: June 22, 2016 / Version: 1.2.3.1
Jamshaid sadiq

how it works with live connect api?

Posted on: June 15, 2016 / Version: 1.2.3.1
Filipe Miranda rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Does anyone got it to work with windows phone?

Posted on: April 25, 2016 / Version: 1.2.3.1
Louis Taljaard rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

@ricardo.charf I have logged a new issue for this under the github project: Xamarin.Auth is not working under Android anymore #109 @Xamarin please take note of this and action urgently!

Posted on: April 11, 2016 / Version: 1.2.3.1
Dave Nash rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I downloaded the 1.3.0-alpha version of Xamarin.Auth to gain support for Windows, obviously it's still in alpha but has anyone got an idea how to integrate the library into a Windows renderer?

Posted on: April 4, 2016 / Version: 1.2.3.1
ricardo.charf rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

When I try to login to facebook in Xamarin.droid, the app crashes with a null reference exception on a thread that belongs to the Xamarin.auth code.

Anyone know How to solve this?

The component works fine on iOS

Posted on: April 4, 2016 / Version: 1.2.3.1
Shawn Anderson rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Decent, however it really needs a Windows implementation to make it really useful for the full Xamarin Forms platform

Posted on: March 16, 2016 / Version: 1.2.3.1
Pablo Andrés Cancinos Castillo rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Really nice component! Very easy to use!!

The only thing is that I try to add it to my project from nuget packages manager and it gave me a lot of issues! Beside that, really nice auth tool!

Posted on: March 13, 2016 / Version: 1.2.3.1
Lev Ginsburg

Windows 10 (UWP) support would be greatly appreciated.

Posted on: January 16, 2016 / Version: 1.2.3.1
George Edwards rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

It would be really nice to see this updated and to have some proper PCL support. Also, samples / docs on integrating with Google, Facebook, Amazon, Twitter etc. would really help many of the people asking questions about this. It would be good to see Xamarin implement some processes for keeping all of their "Active" / "Maintained" Libraries up to date.

Posted on: January 5, 2016 / Version: 1.2.3.1
Kevin Kraemer rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

code needs to be updated. Have been running into exception "Could not save account to KeyChain: InteractionNotAllowed". I see a pull request (https://github.com/xamarin/Xamarin.Auth/pull/80) submitted for this a year ago but never merged.

Posted on: December 18, 2015 / Version: 1.2.3.1
Sudhir Muthal

Can anyone suggest how to use this code to create custom login without facebook in cross platform

Posted on: December 14, 2015 / Version: 1.2.3.1
yin shen rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Use webview to implement OAuth in mobile is not good. Because some mobile app do not need you to input username and password. You can just click a button to login in with another app.

Posted on: November 25, 2015 / Version: 1.2.3.1
Mats Andersson rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

The component needs an update, doesnt work on ios 9 due to ”An SSL error has occurred and a secure connection to the server cannot be made”.

Temporary solution would be to add NSAppTransportSecurity key in info.Plist. https://developer.xamarin.com/guides/ios/platform_features/introduction_to_ios9/ats/

Posted on: November 3, 2015 / Version: 1.2.3.1
purposecode

hi,

Xamarin.Auth works fine in Android.

But in case of iOS, the program execution hangs on PresentViewController (auth.GetUI (), true, null);

i am using iOS 9.1 .

any body have an idea about this issue ?

Posted on: October 27, 2015 / Version: 1.2.3.1
Jeff Lim rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

New question on this component:..

Click on the Cancel button from LinkedIn OAuth login form/page doesn't trigger any action? How to handle it? AllowCancelled = true (already tried that. )

'--------------------------------------------------------------------------------------------

Xamarin.Auth iOS unified Sample not working?

I tried the above Sample under a iOS unified project. However, I hit an error at this line: "UIViewController vc = auth.GetUI (); " after clicked on the Login button from the main screen.

error message: System.MissingMemberException. Method not found for: 'UIKit.UIWebView.set_Delegate'.

I have to re-rate the rating from 4 to 2 now.


Belows were the comments made few months ago (before i switch it to 64 bit.). Bingo, ~! Here are my achievement via the authentication component:

  1. Twittter with Oauth v1 - ok
  2. Facebook with Oauth v2 -ok
  3. Google with Oauth v2 -ok
  4. LinkedIn with Oauth v1 -ok
  5. LinkedIn with Oauth v2 (but not stable).

The authentication with google is abit tricky. Overall quite happy with it, at least done what I want.

But, got some issue on the Dictionary in OAuth1Request(). Thought about to post something to LinkedIn via its Share API in json format: https://api.linkedin.com/v1/people/~/shares However, have no idea how to place the hierarchy object as a value to the dictionary.
My assumption is the 'OAuth1Request()' will actually serialise the key and value in the dictionary before a post. Hmmm... pls help . any one?

Posted on: August 10, 2015 / Version: 1.2.3
sagar patel

Hi, Developers,

I am thanking you for providing such nice useful component, and i am using this component in my app, for facebook login, and it works perfect, i found some limitation in oAuth2Authenticatior method, while i am trying to make reAuthorization(auth_type) in facebook , for that i need auth_type parameter to make it work in android, but could not found such parameter.

So i failed to make it work pls refer this link what i m trying to implement (https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2#re-asking-declined-permissions)

var auth = new OAuth2Authenticator ( clientId: "2342354534657", scope: "email", authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));

i need to add the "auth_type=rerequest" in OAuth2Authenticator, can you help to make it work..? Your help will be appreciated..

Posted on: June 1, 2015 / Version: 1.2.3.1
Jose Manuel Ojeda rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Hi, I'm using xamarin forms with a custom page render to present the auth ui, how can I navigate back to a xamarin form page after successfully login of facebook?

auth.Completed += (sender, eventArgs) => { //DismissViewController (true, null); if (eventArgs.IsAuthenticated) {

                here I want to navigate back to a xamarin form page
            }
        };
Posted on: April 22, 2015 / Version: 1.2.3.1
Michael Bartlett rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Tried the "it's that easy" example and get an error.

Posted on: February 13, 2015 / Version: 1.2.3.1
Devin Smith rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I have used this component successfully within my forms (unified API) application logging into Twitter, shame it doesn't extend to Windows as I had to implement my own version. Very easy to implement.

http://www.datadruid.co.uk

Posted on: January 26, 2015 / Version: 1.2.3.1
Carl Barton rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Would be very beneficial to have a Xamarin.Forms implementation supporting iOS, Android and Windows Phone.

Posted on: January 21, 2015 / Version: 1.2.3.1
Sebastian Iacomuzzi

Hi,

Could you please submit a new component version? I need the ShowUIErrors feature: https://github.com/xamarin/Xamarin.Auth/blame/master/src/Xamarin.Auth/WebAuthenticator.cs#L62

Thanks!

Posted on: January 2, 2015 / Version: 1.2.3
Dennis Welu rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

As Jeff Lim points out Google auth is possible...but tricky. Web research leads you eventually here: http://stackoverflow.com/questions/25520180/google-account-login-integration-for-android-xamarin/25766256#25766256 for what I would consider being the "workaround".

Posted on: November 8, 2014 / Version: 1.2.3
peter lin rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Facebook, Weibo works find!

But some problems with Strava API

the authentication webview pops up "Authentication Error - unknown_user"

Posted on: October 6, 2014 / Version: 1.2.3
Corey Perkins rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Using with Xamarin Forms you can authenticate with Facebook but you cannot go any further than that on iOS. It will display the redirect url (https://www.facebook.com/connect/login_success.html) with a plain white background and nasty red text "SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone. See the Facebook Help Center for more information." on iOS. It keeps the user stuck on that page. I have yet to find a way around that despite hours of hacking.

Works fine on Android.

Posted on: October 1, 2014 / Version: 1.2.3
Matteo rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Still does not work with google.. please solve!!

Posted on: September 23, 2014 / Version: 1.2.3
Jesse Mock

I have had this working for a while, but when I deploy it to my iPhone, even after completely removing the app from the iPhone, the AccountStore is holding on to the Account. I need to wipe it out somehow

Posted on: August 29, 2014 / Version: 1.2.2
Bryan Rodríguez rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I have problems with the GetUI in iOS. The Cancel button not dismiss the ViewController. Any help?

Posted on: August 26, 2014 / Version: 1.2.2
Suhail MUHAMMED rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

This is just unbelievable that Xamarin has not yet come out with a fix for the issue of login failure with Google API.

Posted on: August 18, 2014 / Version: 1.2.2
Andres Pineda rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Very nice component!! Although, I am having problems authenticating the user though the Facebook Installed App. Have anybody been able to accomplish that with this component or the Authentication is only through the Web UI?

Posted on: April 24, 2014 / Version: 1.2.2
Bart Clement rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Nice idea, but I am unable to get this component to work correctly with the LinkedIn REST API (using OAuth 2.0). I do receive the token, but (almost always) it becomes invalid immediately and LinkedIn returns 401 errors.

Posted on: April 9, 2014 / Version: 1.2.2
Sherif Guirguis

there is a bug when trying to use Xamarin.Auth with iOS 7.0.6 as it shows access is denied for user when trying to login to Facebook.

Posted on: March 3, 2014 / Version: 1.2.2
Tim B rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

The Google API does not work. Google specifically states to either use http://localhost with a port or their URN scheme as a callback, yet this library doesn't seem to be able to detect either of them and signal a Completed event. See thread here for more info: http://forums.xamarin.com/discussion/comment/21500/#Comment_21500

Posted on: February 3, 2014 / Version: 1.2.2
luidi fortunato

Hi Everybody,

Can someone publish examples on how to use Auth with FormAuthentication? I am trying to use it, but nothing seems to work and the documentation is very bad.

Thanks, Regards, Luidi

Posted on: December 13, 2013 / Version: 1.2.2
S. J. A. van Rooij rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

OAuth just got a whole lot easier!!! By using this component i've been able to build a complete app in a day!!

If you have an oauth api that you want to use, check out this component!!! But the documentation could be better. It needs an callback url, but had to figure out myself where this was for.

Posted on: October 17, 2013 / Version: 1.2.1
fulgen ninofranco

I changed the clientId to my App ID and tried to logged in, then it works fine, but when I tried to logged in other accounts which don't have an App Id, it doesn't work it returns an error saying "Expected access token in response but did not received one". How could I fix this in order for it to work as dynamic?

Posted on: October 17, 2013 / Version: 1.2.1
Soft Lion rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Does not use native SDK : opens a webview instead.

The install doc seems to be only for iOS. The demo project uses a nice recipe : async call with the ui scheduler to get back to ui thread automagically.

Posted on: October 17, 2013 / Version: 1.0.1