Esempio n. 1
0
        public async Task <AccessToken> GetToken()
        {
            var header = _clientProvider.GetHttpClientHeader();

            //Define Headers
            header.Accept.Clear();
            header.Accept.Add(_clientProvider.GetNewMTVQHeaderValue("application/json"));
            header.Authorization = _clientProvider.GetAuthenticationHeaderValue("Basic", clientLauncherToken);

            //Prepare Request Body
            List <KeyValuePair <string, string> > requestData = new List <KeyValuePair <string, string> >();

            requestData.Add(new KeyValuePair <string, string>("grant_type", "client_credentials"));

            //Request Token
            var request = await _clientProvider.PostAsync(oauthTokenEndpoint, _clientProvider.MakeRequestBody(requestData));

            var response = await request.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <AccessToken>(response));
        }