Bearer token authentication
- Last Updated: April 19, 2022
- 1 minute read
- DataDirect Connectors
- JDBC
- Autonomous REST Connector 6.0
- Documentation
To configure the driver to use bearer token authentication:
- Configure the minimum properties required for a connection:
- If you are using a Model file, set the Config property to provide the name and location of the Model file. For example, C:/path/to/myrest.rest.
- If you are using the Sample property, set the Sample property to
specify the endpoint that the want to connect to and sample. For example,
https://example.com/countries/.
- Set the AuthenticationMethod property to
BearerToken. - Set the SecurityToken property to specify your the API Token, configured as BearerToken, used for authentication.
- Optionally, specify values for any additional properties you want to configure.
The following examples demonstrate a session using a Model file with bearer token authentication enabled.
For a connection URL:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:autorest:https://example.com/;AuthenticationMethod=BearerToken;
Config=C:/path/to/myrest.rest;SecurityToken=C3TQH9zjwek4CgJCU-4Mxb2DxLNfI2LB3a-dNfpWYx;");
For a data source:
AutoRESTDataSource mds = new AutoRESTDataSource();
mds.setDescription("My Autonomous REST Data Source");
mds.setAuthenticationMethod("BearerToken");
mds.setConfig("C:/path/to/myrest.rest");
mds.setBearerToken("C3TQH9zjwek4CgJCU-4Mxb2DxLNfI2LB3a-dNfpWYx");