/// <exception cref="GPClientException"></exception>
        public GPConnector GetAppToken(string scope)
        {
            var restRequest = new NewtonsoftJsonRestRequest(@"/oauth2/token", Method.POST);

            restRequest.RequestFormat = DataFormat.Json;
            restRequest.AddHeader("Accept", "application/json");
            restRequest.JsonSerializer.ContentType = "application/x-www-form-urlencoded";
            restRequest.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&scope=" + scope, ParameterType.RequestBody);
            var authenticator = new HttpBasicAuthenticator(ClientID, ClientSecret);

            authenticator.Authenticate(Client, restRequest);
            var response = Client.Execute(restRequest);

            AccessToken = Deserialize <AccessToken>(response.Content);
            return(this);
        }
        private IRestRequest CreateRestRequest(string url, string contentType, Parameter parameter, Method method = Method.POST)
        {
            var restRequest = new NewtonsoftJsonRestRequest(url, method);

            if (parameter != null)
            {
                restRequest.AddParameter(parameter);
            }
            restRequest.AddHeader("Accept", "application/json");

            if (contentType != null)
            {
                restRequest.AddHeader("Content-Type", contentType);
            }

            restRequest.AddHeader("Authorization", "Bearer " + AccessToken.Token);
            return(restRequest);
        }