(auth())
REST APIs for managing Authentication
- getAccess - Get access allowances for a particular workspace
- getAccessToken - Get or refresh an access token for the current workspace.
- getUser - Get information about the current user.
- validateApiKey - Validate the current api key.
Checks if generation is permitted for a particular run of the CLI
package hello.world;
import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetWorkspaceAccessRequest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetWorkspaceAccessResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
RyanTest sdk = RyanTest.builder()
.security(Security.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build())
.build();
GetWorkspaceAccessRequest req = GetWorkspaceAccessRequest.builder()
.build();
GetWorkspaceAccessResponse res = sdk.auth().getAccess()
.request(req)
.call();
if (res.accessDetails().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetWorkspaceAccessRequest | ✔️ | The request object to use for the request. |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4XX, 5XX | */* |
Get or refresh an access token for the current workspace.
package hello.world;
import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetAccessTokenRequest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetAccessTokenResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Error, Exception {
RyanTest sdk = RyanTest.builder()
.build();
GetAccessTokenRequest req = GetAccessTokenRequest.builder()
.workspaceId("<value>")
.build();
GetAccessTokenResponse res = sdk.auth().getAccessToken()
.request(req)
.call();
if (res.accessToken().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetAccessTokenRequest | ✔️ | The request object to use for the request. |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/Error | 4XX | application/json |
models/errors/SDKError | 5XX | */* |
Get information about the current user.
package hello.world;
import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetUserResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Error, Exception {
RyanTest sdk = RyanTest.builder()
.security(Security.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build())
.build();
GetUserResponse res = sdk.auth().getUser()
.call();
if (res.user().isPresent()) {
// handle response
}
}
}
Error Type | Status Code | Content Type |
---|---|---|
models/errors/Error | 4XX | application/json |
models/errors/SDKError | 5XX | */* |
Validate the current api key.
package hello.world;
import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.ValidateApiKeyResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Error, Exception {
RyanTest sdk = RyanTest.builder()
.security(Security.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build())
.build();
ValidateApiKeyResponse res = sdk.auth().validateApiKey()
.call();
if (res.apiKeyDetails().isPresent()) {
// handle response
}
}
}
Error Type | Status Code | Content Type |
---|---|---|
models/errors/Error | 4XX | application/json |
models/errors/SDKError | 5XX | */* |