public string GetAuth() { string _token = string.Empty; Rest.ApplicationPermissions applicationPermissions = new Rest.ApplicationPermissions { clientId = Client_ID, clientSecret = Client_Secret }; ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; var client = new RestClient(Endpoint + "/auth/token"); var request = new RestRequest(Method.POST); request.AddJsonBody(applicationPermissions); IRestResponse response = client.Execute(request); Rest.Auth _auth = new Rest.Auth(); _auth = Newtonsoft.Json.JsonConvert.DeserializeObject <Rest.Auth>(response.Content); _token = _auth.data.accessToken; Token = _token; return(_token); }
public Guid GetAuthTokenFromAuthResponce(IRestResponse restResponse) { string _token = string.Empty; Rest.Auth _auth = new Rest.Auth(); _auth = Newtonsoft.Json.JsonConvert.DeserializeObject <Rest.Auth>(restResponse.Content); _token = _auth.data.accessToken; Token = _token; return(new Guid(_token)); }