All URIs are relative to https://api.voucherify.io
| Method | HTTP request | Description |
|---|---|---|
| GenerateOauthToken | POST /v1/oauth/token | Generate OAuth 2.0 Token |
| IntrospectOauthToken | POST /v1/oauth/introspect | Introspect OAuth 2.0 Token |
| RevokeOauthToken | POST /v1/oauth/token/revoke | Revoke OAuth 2.0 Token |
OAuthTokenGenerateResponseBody GenerateOauthToken (string grantType = null, string scope = null)
Generate OAuth 2.0 Token
Generate an OAuth 2.0 token for an API client. The token can be used to authorize access to the Voucherify API. The token inherits the permissions and IP whitelists of the API key that is used to generate the OAuth token. You can define the scope that limits its usage. You can generate up to 1000 OAuth tokens per project. The token expires in 900 seconds (15 minutes). If the API key that is used to generate the OAuth token is deleted or blocked, you cannot generate new OAuth tokens and the existing ones will stop working within one minute. If the API key used to generate an OAuth token is regenerated, the OAuth token can still be used. 🚧 Format of scope values Separate the values of the scope property with spaces.
using System.Collections.Generic;
using System.Diagnostics;
using Voucherify.Api;
using Voucherify.Client;
using Voucherify.Model;
namespace Example
{
public class GenerateOauthTokenExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.voucherify.io";
// Configure API key authorization: X-App-Id
config.AddApiKey("X-App-Id", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Id", "Bearer");
// Configure API key authorization: X-App-Token
config.AddApiKey("X-App-Token", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Token", "Bearer");
var apiInstance = new OAuthApi(config);
var grantType = "client_credentials"; // string | Gives an access token outside of the context of a user. (optional)
var scope = "scope_example"; // string | Defines the scope of possible actions that can be done with the OAuth token. The `api` scope allows using the server-side API. The `client_api` scope allows using the whole client-side API. The values are space-delimited; do **not** use commas to separate the values. Allowed values: `api`, `assets`, `async-actions`, `campaigns`, `categories`, `client_api`, `client_consents`, `client_customers`, `client_events`, `client_promotions`, `client_publish`, `client_qualifications`, `client_redeem`, `client_redemptions`, `client_validate`, `client_validations`, `client_vouchers`, `consents`, `customers`, `events`, `exports`, `locations`, `loyalties`, `metadata-schemas`, `orders`, `product-collections`, `products`, `promotions`, `publications`, `qualifications`, `redemptions`, `referrals`, `rewards`, `segments`, `skus`, `task-results`, `templates`, `trash-bin`, `validation-rules-assignments`, `validation-rules`, `validations`, `vouchers`. (optional)
try
{
// Generate OAuth 2.0 Token
OAuthTokenGenerateResponseBody result = apiInstance.GenerateOauthToken(grantType, scope);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.GenerateOauthToken: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This returns an ApiResponse object which contains the response data, status code and headers.
try
{
// Generate OAuth 2.0 Token
ApiResponse<OAuthTokenGenerateResponseBody> response = apiInstance.GenerateOauthTokenWithHttpInfo(grantType, scope);
Debug.Write("Status Code: " + response.StatusCode);
Debug.Write("Response Headers: " + response.Headers);
Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.GenerateOauthTokenWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}| Name | Type | Description | Notes |
|---|---|---|---|
| grantType | string | Gives an access token outside of the context of a user. | [optional] |
| scope | string | Defines the scope of possible actions that can be done with the OAuth token. The `api` scope allows using the server-side API. The `client_api` scope allows using the whole client-side API. The values are space-delimited; do not use commas to separate the values. Allowed values: `api`, `assets`, `async-actions`, `campaigns`, `categories`, `client_api`, `client_consents`, `client_customers`, `client_events`, `client_promotions`, `client_publish`, `client_qualifications`, `client_redeem`, `client_redemptions`, `client_validate`, `client_validations`, `client_vouchers`, `consents`, `customers`, `events`, `exports`, `locations`, `loyalties`, `metadata-schemas`, `orders`, `product-collections`, `products`, `promotions`, `publications`, `qualifications`, `redemptions`, `referrals`, `rewards`, `segments`, `skus`, `task-results`, `templates`, `trash-bin`, `validation-rules-assignments`, `validation-rules`, `validations`, `vouchers`. | [optional] |
OAuthTokenGenerateResponseBody
- Content-Type: application/x-www-form-urlencoded
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Returns details about the token to be used and its expiration times. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OAuthTokenIntrospectResponseBody IntrospectOauthToken (string accessToken = null)
Introspect OAuth 2.0 Token
Introspect an OAuth 2.0 token for an API client.
using System.Collections.Generic;
using System.Diagnostics;
using Voucherify.Api;
using Voucherify.Client;
using Voucherify.Model;
namespace Example
{
public class IntrospectOauthTokenExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.voucherify.io";
// Configure API key authorization: X-App-Id
config.AddApiKey("X-App-Id", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Id", "Bearer");
// Configure API key authorization: X-App-Token
config.AddApiKey("X-App-Token", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Token", "Bearer");
var apiInstance = new OAuthApi(config);
var accessToken = "accessToken_example"; // string | An OAuth 2.0 token generated with the API token and key. (optional)
try
{
// Introspect OAuth 2.0 Token
OAuthTokenIntrospectResponseBody result = apiInstance.IntrospectOauthToken(accessToken);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.IntrospectOauthToken: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This returns an ApiResponse object which contains the response data, status code and headers.
try
{
// Introspect OAuth 2.0 Token
ApiResponse<OAuthTokenIntrospectResponseBody> response = apiInstance.IntrospectOauthTokenWithHttpInfo(accessToken);
Debug.Write("Status Code: " + response.StatusCode);
Debug.Write("Response Headers: " + response.Headers);
Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.IntrospectOauthTokenWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}| Name | Type | Description | Notes |
|---|---|---|---|
| accessToken | string | An OAuth 2.0 token generated with the API token and key. | [optional] |
OAuthTokenIntrospectResponseBody
- Content-Type: application/x-www-form-urlencoded
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Returns details about an existing token and its expiration times. If an nonexistent token is sent in the request, the response returns that it is inactive. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
void RevokeOauthToken (string accessToken = null)
Revoke OAuth 2.0 Token
Revoke an OAuth 2.0 token for an API client. Once revoked, the token cannot be used anymore.
using System.Collections.Generic;
using System.Diagnostics;
using Voucherify.Api;
using Voucherify.Client;
using Voucherify.Model;
namespace Example
{
public class RevokeOauthTokenExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.voucherify.io";
// Configure API key authorization: X-App-Id
config.AddApiKey("X-App-Id", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Id", "Bearer");
// Configure API key authorization: X-App-Token
config.AddApiKey("X-App-Token", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("X-App-Token", "Bearer");
var apiInstance = new OAuthApi(config);
var accessToken = "accessToken_example"; // string | An OAuth 2.0 token generated with the API token and key. (optional)
try
{
// Revoke OAuth 2.0 Token
apiInstance.RevokeOauthToken(accessToken);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.RevokeOauthToken: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This returns an ApiResponse object which contains the response data, status code and headers.
try
{
// Revoke OAuth 2.0 Token
apiInstance.RevokeOauthTokenWithHttpInfo(accessToken);
}
catch (ApiException e)
{
Debug.Print("Exception when calling OAuthApi.RevokeOauthTokenWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}| Name | Type | Description | Notes |
|---|---|---|---|
| accessToken | string | An OAuth 2.0 token generated with the API token and key. | [optional] |
void (empty response body)
- Content-Type: application/x-www-form-urlencoded
- Accept: Not defined
| Status code | Description | Response headers |
|---|---|---|
| 204 | Returns no content if the OAuth 2.0 token is revoked successfully. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]