当前位置: 首页>>代码示例>>C#>>正文


C# ApiClient.SetAuthenticationInfo方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:zardaloop,项目名称:Emby.WindowsPhone,代码行数:25,代码来源:ScheduledAgent.cs

示例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);
            }
        }
开发者ID:timextreasures,项目名称:Emby.WindowsPhone,代码行数:27,代码来源:AudioPlayer.cs


注:本文中的ApiClient.SetAuthenticationInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。