本文整理匯總了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);
}