本文整理汇总了C#中Authenticator.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Authenticator.Authenticate方法的具体用法?C# Authenticator.Authenticate怎么用?C# Authenticator.Authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authenticator
的用法示例。
在下文中一共展示了Authenticator.Authenticate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
var driveAuthenticator = new Authenticator();
driveAuthenticator.Authenticate("test");
this.googleDriveServiceProvider = new GoogleDriveServiceProvider(driveAuthenticator);
this.testee = new FileDownloader(this.googleDriveServiceProvider);
}
示例2: Setup
public void Setup()
{
var authenticator = new Authenticator();
authenticator.Authenticate("test");
var serviceProvider = new GoogleDriveServiceProvider(authenticator);
this.testee = new FolderSynchronizer(new FilesGetter(serviceProvider), new FileDownloader(serviceProvider));
}
示例3: Authenticate_WhereDownstreamResultEmpty_ReturnsFalse
public async Task Authenticate_WhereDownstreamResultEmpty_ReturnsFalse()
{
// arrange
var proxy = new AuthenticatorProxyWithResult("");
authenticator = new Authenticator(proxy);
// act
var result = await authenticator.Authenticate("url");
Assert.IsFalse(result.IsSuccess);
}
示例4: Authenticate_WhereDownstreamResultOccurs_ReturnsSuccess
public async Task Authenticate_WhereDownstreamResultOccurs_ReturnsSuccess()
{
// arrange
var proxy = new AuthenticatorProxyWithResult("foo");
authenticator = new Authenticator(proxy);
// act
var result = await authenticator.Authenticate("url");
Assert.IsTrue(result.IsSuccess);
}
示例5: Synchronize_WhenFolderIsSynchronize_ThenStructureIsCorrect
public void Synchronize_WhenFolderIsSynchronize_ThenStructureIsCorrect()
{
// Arrange
var authenticator = new Authenticator();
authenticator.Authenticate("test");
var filesGetter = new FilesGetter(new GoogleDriveServiceProvider(authenticator));
var files = filesGetter.GetDriveFiles(GoogleDriveConstants.FolderMimeType).ToList();
// Act
string rootFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\TestGoogle";
this.testee.SynchronizeFolder(
files[1],
rootFolder);
// Assert
Directory.Exists(rootFolder).Should().BeTrue();
Directory.GetDirectories(rootFolder).Length.Should().Be(1);
}
示例6: Setup
public void Setup()
{
Authenticator driveAuthenticator = new Authenticator();
driveAuthenticator.Authenticate("test");
this.testee = new FilesGetter(new GoogleDriveServiceProvider(driveAuthenticator));
}
示例7: InnerRun
protected override void InnerRun()
{
Succeeded = false;
PendingUserActivation = true;
ShouldRetry = true;
DoxApi api = new DoxApi(_serviceUrl);
IDoxSession session = null;
if (!string.IsNullOrEmpty(DeviceToken))
{
session = api.CreateSessionFromDeviceToken(_loginName, DeviceToken, ApiHelper);
if (session == null && api.Error.IsConnectionError())
{
PendingUserActivation = false;
ErrorMessage = Properties.Resources.ConnectionErrorDuringUpload;
return;
}
}
if (session == null)
{
// show login dialog
var nativeWindow = new NativeWindow();
nativeWindow.AssignHandle(IntPtr.Zero);
_loginUi.NativeWindow = nativeWindow;
_loginUi.RegisterTabVisible = false;
_loginUi.LoginFieldEnabled = false;
var authenticator = new Authenticator(_loginUi);
authenticator.Api = api;
authenticator.ApiHelper = ApiHelper;
bool cancelSend;
session = authenticator.Authenticate(_loginName, null, out cancelSend);
if (cancelSend)
{
ShouldRetry = false;
PendingUserActivation = false;
Logger.LogInfo("User cancelled send");
ErrorMessage = "Unable to log in.";
return;
}
}
if (session == null)
{
return; // something weird is happening, try again later
}
DeviceToken = session.Credentials.DeviceToken;
OptionApi.SetEncrypted("SendLinkDeviceToken", DeviceToken, _entropy);
OptionApi.SetEncrypted("SendLinkAccountId", session.CurrentUser.AccountId, _entropy);
OptionApi.SetEncrypted("SendLinkUserId", session.CurrentUser.Id, _entropy);
if (session.CurrentUser.IsValidated)
{
PendingUserActivation = false;
Succeeded = true;
ErrorMessage = string.Empty;
}
}
示例8: Authenticate_WhereDownstreamResultOccurs_ReturnsToken
public async Task Authenticate_WhereDownstreamResultOccurs_ReturnsToken()
{
// arrange
var proxy = new AuthenticatorProxyWithResult("foo");
authenticator = new Authenticator(proxy);
// act
var result = await authenticator.Authenticate("url");
Assert.AreEqual("foo", result.AccessToken);
}