Client authentication
It is your responsibility to perform user authentication by calling OneginiClient#UserClient#authenticateClient
whenever a Resource Gateway responds with a 401 unauthorized status code.
The DeviceClient#authenticateDevice
method performs client authentication. The Android SDK uses client credentials to request an access token object, which is used to perform anonymous resource calls. To call the authenticateDevice
method two arguments have to be passed:
String[]
scopes the client authentication is requested forOneginiDeviceAuthenticationHandler
interface implementation
Example code - authenticating a client
private void authenticateDevice() {
OneginiSDK.getOneginiClient(this).getDeviceClient().authenticateDevice(new String[]{ "application-details" }, new OneginiDeviceAuthenticationHandler() {
@Override
public void onSuccess() {
// fetch anonymous application details
}
@Override
public void onError(final OneginiDeviceAuthenticationError error) {
final @OneginiDeviceAuthenticationError.DeviceAuthenticationErrorType int errorType = error.getErrorType();
if (errorType == OneginiDeviceAuthenticationError.DEVICE_DEREGISTERED) {
new DeregistrationUtil(InfoActivity.this).onDeviceDeregistered();
}
}
}
);
}