A guided walk-through for setting up a service account for Zywave APIs through the use of refresh tokens and offline access
Zywave API V2.x is focused on accessing APIs on behalf of a user. In scenarios where it is desired to use the APIs without the direct involvement of a user a service account can be created to make API calls on behalf of.
offline_access
scope enabled, in addition to any other scopes required by the APIs you intend to useProfile
header, read the documentation on explicit profilesExample:
curl --request POST --url https://auth.zywave.com/connect/token --header 'Content-Type: application x-www-form-urlencoded' --data "client_id=[YOUR_CLIENT_ID]" --data "client_secret=[YOUR_CLIENT_SECRET]" --data "grant_type=refresh_token" --data "refresh_token=[YOUR_REFRESH_TOKEN]"
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://auth.zywave.com/connect/token");
request.Content = new StringContent("client_id=[YOUR_CLIENT_ID]&client_secret=[YOUR_CLIENT_SECRET]&grant_type=refresh_token&refresh_token=[YOUR_REFRESH_TOKEN]");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application x-www-form-urlencoded");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://auth.zywave.com/connect/token"))
.POST(BodyPublishers.ofString("client_id=[YOUR_CLIENT_ID]&client_secret=[YOUR_CLIENT_SECRET]&grant_type=refresh_token&refresh_token=[YOUR_REFRESH_TOKEN]"))
.setHeader("Content-Type", "application x-www-form-urlencoded")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
fetch('https://auth.zywave.com/connect/token', {
method: 'POST',
headers: {
'Content-Type': 'application x-www-form-urlencoded'
},
body: 'client_id=[YOUR_CLIENT_ID]&client_secret=[YOUR_CLIENT_SECRET]&grant_type=refresh_token&refresh_token=[YOUR_REFRESH_TOKEN]'
});
import requests
headers = {
'Content-Type': 'application x-www-form-urlencoded',
}
data = 'client_id=[YOUR_CLIENT_ID]&client_secret=[YOUR_CLIENT_SECRET]&grant_type=refresh_token&refresh_token=[YOUR_REFRESH_TOKEN]'
response = requests.post('https://auth.zywave.com/connect/token', headers=headers, data=data)