Authentication
5 min
use the oauth2 client credentials supplied by your device park administrator create the client once before calling other sdk methods and reuse it during the test run before you begin set the credentials as environment variables export devicepark client id=your client id export devicepark client secret=your client secret keep clientsecret outside source control, ci output and application logs load credentials from your secret manager or environment the sdk base url is https //devicepark testinium io in the examples below credentials are the only secret values; the url is not read from an environment variable by sdk version 1 0 0 create the client create one client for the test run and close it during cleanup choose your sdk language import io testinium devicepark deviceparkapiclient; import io testinium devicepark authentication credentials credentials; try (deviceparkapiclient client = deviceparkapiclient builder() url("https //devicepark testinium io") credentials(credentials of( system getenv("devicepark client id"), system getenv("devicepark client secret"))) timeout(30) build()) { // call sdk methods with this client }import { credentials, deviceparkapiclient } from "@devicepark/public sdk"; const client = deviceparkapiclient builder() url("https //devicepark testinium io") credentials(credentials fromenvironment()) timeout(30) build(); try { // call sdk methods with this client } finally { await client close(); } java uses credentials of( ) node js credentials fromenvironment() reads devicepark client id and devicepark client secret in node js, credentials already available in application configuration can be passed with credentials create(clientid, clientsecret) or credentialsfrom(clientid, clientsecret) configuration value required java node js url yes url( ) url( ) clientid yes credentials of( ) environment or credentials create( ) clientsecret yes credentials of( ) environment or credentials create( ) timeout no seconds; default 60 seconds; default 60 token management the client requests a token on the first sdk operation, keeps it in memory and renews it before expiration token renewal uses a 60 second safety margin application code does not need a token refresh task create one client per test run creating a client for every method call discards the cached token next step list the devices available to your account /devices/list devices
