protected override async Task <Account> PerformAuthenticate() { var account = CurrentBasicAccount ?? GetAccount <BasicAuthAccount>(Identifier); if (account?.IsValid() == true) { return(CurrentAccount = account); } authenticator = CreateAuthenticator(); await authenticator.PrepareAuthenticator(); if (CurrentShowAuthenticator != null) { CurrentShowAuthenticator(authenticator); } else { ShowAuthenticator(authenticator); } var token = await authenticator.GetAuthCode(); if (string.IsNullOrEmpty(token)) { throw new Exception("Null token"); } account = new BasicAuthAccount { Key = token }; account.Identifier = Identifier; SaveAccount(account); CurrentAccount = account; return(account); }
/// <summary> /// Initializes a new instance of the <see cref="T:SimpleAuth.BasicAuthApi"/> class. /// </summary> /// <param name="identifier">This is used to store and look up credentials/cookies for the API</param> /// <param name="encryptionKey">Encryption key used to store information.</param> /// <param name="loginUrl">Login URL for the credentials to be tested against.</param> /// <param name="handler">Handler.</param> public BasicAuthApi(string identifier, string encryptionKey, string loginUrl, HttpMessageHandler handler = null) : base(identifier, encryptionKey, handler) { LoginUrl = loginUrl; authenticator = new BasicAuthAuthenticator(Client, loginUrl); ClientSecret = encryptionKey; ClientId = identifier; }
public BasicAuthApi(string identifier, string loginUrl, HttpMessageHandler handler = null) : base(identifier, handler) { LoginUrl = loginUrl; authenticator = new BasicAuthAuthenticator(Client, loginUrl); #if __IOS__ ShowAuthenticator = (auth) => { var invoker = new Foundation.NSObject(); invoker.BeginInvokeOnMainThread(() => { var controller = new BasicAuthController(auth); controller.Show(); }); }; #endif }
public BasicAuthController(BasicAuthAuthenticator authenticator) { this.authenticator = authenticator; }