Authentication Endpoints
Last updated
Last updated
Copyright 2024 Ocean Protocol Foundation Ltd.
Provider offers an alternative to signing each request, by allowing users to generate auth tokens. The generated auth token can be used until its expiration in all supported requests. Simply omit the signature parameter and add the AuthToken request header based on a created token.
Please note that if a signature parameter exists, it will take precedence over the AuthToken headers. All routes that support a signature parameter support the replacement, with the exception of auth-related ones (createAuthToken and deleteAuthToken need to be signed).
Endpoint: GET /api/services/createAuthToken
Description: Allows the user to create an authentication token that can be used to authenticate requests to the provider API, instead of signing each request. The generated auth token can be used until its expiration in all supported requests.
Parameters:
address
: The Ethereum address of the consumer (Optional).
nonce
: A unique identifier for this request, to prevent replay attacks (Required).
signature
: A digital signature proving ownership of the address
. The signature should be generated by signing the hashed concatenation of the address
and nonce
parameters (Required).
expiration
: A valid future UTC timestamp representing when the auth token will expire (Required).
Curl Example:
Inside the angular brackets, the user should provide the valid values for the request.
Response:
Allows the user to delete an existing auth token before it naturally expires.
Parameters
Returns: Success message if token is successfully deleted. If the token is not found or already expired, returns an error message.
Replace <provider_url>
, <your_address>
, <your_token>
, and <your_signature>
with actual values. This script sends a DELETE request to the deleteAuthToken
endpoint and logs the response. Please ensure that axios
is installed in your environment (npm install axios
).