How to Authorize with the SevenCorners API

The code seen below is the C# code showing what steps are needed to get the authorization bearer header to use when doing any calls that require authorization.

//Setting Agent Variables
string grant_type = "client_credentials";
string APIKey = "YOUR API KEY HERE"; //YOU MUST ENTER A KEY FOR THIS TO WORK
string AuthorizationKey = "";
//Creating Token Request
string TokenURL = "https://api.sevencorners.com/token";
var client = new RestClient(TokenURL);
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Accept", "application/json");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=" + grant_type + "&client_id=" + APIKey, ParameterType.RequestBody);
//Handle Response
IRestResponse response = client.Execute(request);
//Evaluate Response Code (this is not done in this example)
string rcode = response.StatusCode.ToString();
//Set AuthorizationKey
string[] values = response.Content.Split(',');
string[] subvalues = values[0].Split(':');
AuthorizationKey = subvalues[1].TrimStart('"').TrimEnd('"');
//AuthorizationHeader used for subsequent calls to API
//request.AddHeader("Authorization", "Bearer "+AuthorizationKey);
//Prints out the Key to validate you have the long string representation (TESTING)
Console.WriteLine(AuthorizationKey);
Console.ReadLine();

Documents

Privacy Information
Terms of Use
Security Statement

Connect with Seven Corners

About Us
Newsroom
Careers

   

Contact Us