本文整理汇总了C#中ApiClient.SetAuthenticationInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ApiClient.SetAuthenticationInfo方法的具体用法?C# ApiClient.SetAuthenticationInfo怎么用?C# ApiClient.SetAuthenticationInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiClient
的用法示例。
在下文中一共展示了ApiClient.SetAuthenticationInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateClient
private static void CreateClient()
{
try
{
_logger.Info("Creating API Client");
var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() };
var server = ApplicationSettings.Get<ServerInfo>(Constants.Settings.DefaultServerConnection);
if (server == null)
{
_logger.Info("No server details found");
return;
}
var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress;
var client = new ApiClient(MediaBrowserLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider());
client.SetAuthenticationInfo(server.AccessToken, server.UserId);
_logger.Info("Client created");
_apiClient = client;
}
catch (Exception ex)
{
_logger.FatalException("Error creating ApiClient", ex);
}
}
示例2: CreateClient
private static void CreateClient()
{
try
{
_logger.Info("Creating Client");
var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() };
var server = ApplicationSettings.Get<ServerInfo>(Constants.Settings.DefaultServerConnection);
var auth = ApplicationSettings.Get<AuthenticationResult>(Constants.Settings.AuthUserSetting);
if (server == null || auth == null || auth.User == null)
{
if (server == null) _logger.Info("No server information!");
if(auth == null) _logger.Info("No authentication info");
if(auth != null && auth.User == null) _logger.Info("No User info available");
return;
}
var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress;
var client = new ApiClient(_mbLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider());
client.SetAuthenticationInfo(auth.AccessToken, auth.User.Id);
_apiClient = client;
}
catch (Exception ex)
{
_logger.FatalException("Error creating ApiClient", ex);
}
}