예제 #1
0
        private void RequestTokenAndSignIn(IDictionary <string, object> parameters)
        {
            parameters.Add("client_id", _apiConfig.ClientId);
            parameters.Add("client_secret", _apiConfig.ClientSecret);

            var client  = new RestClient(_apiConfig.BaseUrl + "oauth/token");
            var request = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddParameter("application/x-www-form-urlencoded", AuthHelpers.CreateQueryString(parameters), ParameterType.RequestBody);
            var response   = client.Execute(request);
            var oAuthToken = JsonSerializer.Deserialize <OAuthTokenResponse>(response.Content);

            SignIn(oAuthToken.access_token);
        }