API Authentication
authentication with sparklayer works by creating an oauth client credential for the environment within the sparklayer dashboard and authenticating with an oauth2 flow this ensures that every user that uses the application gets assigned an individualised token environment domain depending on the environment you're accessing, the domain denotes the environment you are using area domain live https //app sparklayer io test https //test app sparklayer io retrieving an access token please note you can retreive the client id and secret from the sparklayer dashboard https //app sparklayer io/configuration/api you can create a post request to the /api/auth/token using the domain above it must have a header of content type=application/json and the site id provided from the dashboard when creating an api key please note it's recommended to set the user agent to help us debug any issues you may encounter { "grant type" "client credentials", "client id" "c466d1fb 1af1 4437 a25c 03e8f94814bf", "client secret" "7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv" } if the details are correct you will recieve the below { "token type" "bearer", "expires in" 3600, "access token" "7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv" } to use the access token that you retrieved, you will need to send it as a header with all of your requests the header should look like this item details authorization bearer 7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv please note make sure to replace 7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv with your actual access token once the token expires it is no longer valid example auth request post /api/auth/token http/1 1 site id exampleclient content type application/json host app sparklayer io user agent exampleclient { "grant type" "client credentials", "client id" "c466d1fb 1af1 4437 a25c 03e8f94814bf", "client secret" "7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv" } example auth response http/1 1 200 ok content type application/json access control allow origin access control allow headers authorization, content type, site id access control max age 7200 access control allow methods get, post, put, delete {"token type" "bearer","expires in" 3600,"access token" "7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv"} example api request get /api/v1/price lists http/1 1 site id exampleclient content type application/json host app sparklayer io user agent exampleclient authorization bearer 7za5ltjnkii2wzhu90ftmyjanrcxyjpxsb8sniem3x37b2genuwqyv5tvdflkuwv example api response http/1 1 200 ok content type application/json access control allow origin access control allow headers authorization, content type, site id access control max age 7200 access control allow methods get, post, put, delete \[]