DocumentRepository.cs
/// <summary>
/// Authenticate and get an access token
/// </summary>
/// <returns></returns>
Authenticate and get an access token
Authenticate and get an access token
private async Task<dynamic> GetToken()
        {
            var client = new HttpClient();
            var content = new FormUrlEncodedContent(new List<KeyValuePair<String, String>>
            {
                new KeyValuePair<string, string>("grant_type","client_credentials"),
                new KeyValuePair<string, string>("client_id", _clientId ),
                new KeyValuePair<string, string>("client_secret", _clientSecret),
                new KeyValuePair<string, string>("resource", _resource)
            });
            var response = await client.PostAsync(_tokenUrl, content);
            response.EnsureSuccessStatusCode();
            return JObject.Parse(await response.Content.ReadAsStringAsync());
        }
private async Task < dynamic > GetToken ( ) { var client = new HttpClient ( ) ; var content = new FormUrlEncodedContent ( new List < KeyValuePair < String , String > > { new KeyValuePair < string , string > ( " " , " " ) , new KeyValuePair < string , string > ( " " , _clientId ) , new KeyValuePair < string , string > ( " " , _clientSecret ) , new KeyValuePair < string , string > ( " " , _resource ) } ) ; var response = await client . PostAsync ( _tokenUrl , content ) ; response . EnsureSuccessStatusCode ( ) ; return JObject . Parse ( await response . Content . ReadAsStringAsync ( ) ) ; }
Authenticate and get an access token
Authenticate and get an access token
// todo cache the token until it expires maybe...
None