我剛開始使用Xamarin.Auth,我想通過oauth啓用Facebook登錄。Xamarin.Auth:使用Facebook oauth,如何重定向到我的應用程序?
這裏是我的配置:
public static string ClientId = "client id";
public static string ClientSecret = "client secret";
public static string Scope = "email";
public static string AuthorizeUrl = "https://m.facebook.com/dialog/oauth";
public static string RedirectUrl = "https://www.facebook.com/connect/login_success.html";
public static string AccessTokenUrl = "https://m.facebook.com/dialog/oauth/token";
代碼啓動認證:
public class AuthenticationPageRenderer : PageRenderer
{
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear (animated);
var auth = new OAuth2Authenticator (
Constants.ClientId,
Constants.ClientSecret,
Constants.Scope,
new Uri (Constants.AuthorizeUrl),
new Uri (Constants.RedirectUrl),
new Uri (Constants.AccessTokenUrl)
);
auth.Completed += OnAuthenticationCompleted;
PresentViewController (auth.GetUI(), true, null);
}
async void OnAuthenticationCompleted (object sender, AuthenticatorCompletedEventArgs e)
{
Debug.WriteLine ("AUTH Completed!");
if (e.IsAuthenticated) {
}
}
}
看起來工作得很好,但不是將用戶重定向到https://www.facebook.com/connect/login_success.html,我想他重定向回我的應用程序了。任何幫助非常感謝!
最佳, 薩沙
你爲什麼要提供https://www.facebook.com/connect/login_success.html作爲redirectionURL。 redirectionURL應該是你的應用程序url的權利。 – sameer