J. Joe
J. Joe

Reputation: 381

Can't use OAuth2.0 on xamarin android?

OnCreate:

MainActivity (auth.GetUI (this));

Login();

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code

I installed xamarin.OAuth on nuget. and here is code :

public void Login()
		{
			auth = new OAuth2Authenticator (
				clientId: "3b5a1",
				scope: "",
				authorizeUrl: new Uri ("https://api.instagram.com/oauth/authorize"),
				redirectUrl: new Uri ("http://Instagramcallback.com/callback")
			
			);

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

				if(e.IsAuthenticated)
				{
					
				}
				else
				{
					// errors be showing at here
				}
			};
		}

Fail: I don't see any popup be show on screen.

Upvotes: 0

Views: 323

Answers (1)

SushiHangover
SushiHangover

Reputation: 74144

After you get your auth object, you are not showing the login UI (see the guide in the link below):

On iOS:

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

(The GetUI method returns UINavigationControllers on iOS)

On Android

The following code to present the UI from OnCreate:

StartActivity (auth.GetUI (this));

Getting Started:

https://github.com/xamarin/Xamarin.Auth/blob/master/GettingStarted.md

Upvotes: 1

Related Questions