We use OAuth 2.0, to protect Argip API. Each request to the API must be authorized (in this case must contain Bearer token in authorize header).
Currently we support Client Credential Flow. This flow is used in server-to-server (machine to machine) communication.
In this scenario you need three pieces of information to get proper access token :
Contact our sales department to get Client ID and Client secret.
Please DO NOT generate new access token for each API request! Access token is valid for 8 hours and should be generated right before expiration time.
Please keep in mind that parameters and syntax can be different depending on the shell and operating system.
curl --request POST --url https://identityserver.argip.com.pl/connect/token --header 'content-type: application/json' --data '{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}'
Or the shortest version in Windows cmd
curl -X POST https://identityserver.argip.com.pl/connect/token -d "client_id=PUT_YOUR_CLIENT_ID&client_secret=PUT_YOUR_CLIENT_SECRET&grant_type=client_credentials"
var client = new RestClient("https://identityserver.argip.com.pl/connect/token"); var request = new RestRequest(Method.POST); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", "{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
HttpResponseresponse = Unirest.post("https://identityserver.argip.com.pl/connect/token") .header("content-type", "application/json") .body("{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}") .asString();
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://identityserver.argip.com.pl/connect/token", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}", CURLOPT_HTTPHEADER => array( "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
import http.client conn = http.client.HTTPSConnection("argip.eu.auth0.com") payload = "{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}" headers = { 'content-type': "application/json" } conn.request("POST", "/oauth/token", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
require 'uri' require 'net/http' url = URI("https://identityserver.argip.com.pl/connect/token") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request.body = "{"client_id":"PUT_YOUR_CLIENT_ID","client_secret":"PUT_YOUR_CLIENT_SECRET","grant_type":"client_credentials"}" response = http.request(request) puts response.read_body
Each method above gives the same response:
{ "access_token": "eyJ0.....LOWIXBAyX8JBkKfsg", "token_type": "Bearer" }
You can now extract the access_token property from the response to make authorized requests to our API.