Пример #1
0
        public static TokenCredentials AcquireToken(string authToken, out string subscriptionId)
        {
            string accessToken;
            User   userProfile = new User(authToken);

            subscriptionId = userProfile.MediaAccount.SubscriptionId;
            using (MediaClient mediaClient = new MediaClient(authToken))
            {
                AuthenticationResult authResult = MediaClientCredentials.AcquireToken(mediaClient.MediaAccount).Result;
                accessToken = authResult.AccessToken;
            }
            return(new TokenCredentials(accessToken));
        }
Пример #2
0
        public MediaClient(string authToken, MediaAccount mediaAccount = null)
        {
            if (!string.IsNullOrEmpty(authToken))
            {
                User userProfile = new User(authToken);
                mediaAccount = userProfile.MediaAccount;
            }
            MediaAccount = mediaAccount;
            string settingKey = Constant.AppSettingKey.AzureResourceManagementServiceUrl;
            string serviceUrl = AppSetting.GetValue(settingKey);
            MediaClientCredentials clientCredentials = new MediaClientCredentials(mediaAccount);

            _media = new AzureMediaServicesClient(new Uri(serviceUrl), clientCredentials)
            {
                SubscriptionId = mediaAccount.SubscriptionId
            };
            if (!string.IsNullOrEmpty(MediaAccount.VideoIndexerRegion) &&
                !string.IsNullOrEmpty(MediaAccount.VideoIndexerKey))
            {
                IndexerSetAccountContext();
            }
        }