/** * Acquires a device code from the authority * * @param clientId Identifier of the client requesting the token * @param resource Identifier of the target resource that is the recipient of the * requested token. * @param callback optional callback object for non-blocking execution. * @return A {@link Future} object representing the {@link DeviceCode} of the call. * It contains device code, user code, its expiration date, * message which should be displayed to the user. * @throws AuthenticationException thrown if the device code is not acquired successfully */ public Future<DeviceCode> acquireDeviceCode(final String clientId, final String resource, final AuthenticationCallback<DeviceCode> callback) { validateDeviceCodeRequestInput(clientId, resource); return service.submit( new AcquireDeviceCodeCallable(this, clientId, resource, callback)); }
/** * Acquires a device code from the authority * * @param clientId Identifier of the client requesting the token * @param resource Identifier of the target resource that is the recipient of the * requested token. * @param callback optional callback object for non-blocking execution. * @return A {@link Future} object representing the {@link DeviceCode} of the call. * It contains device code, user code, its expiration date, * message which should be displayed to the user. * @throws AuthenticationException thrown if the device code is not acquired successfully */ public Future<DeviceCode> acquireDeviceCode(final String clientId, final String resource, final AuthenticationCallback<DeviceCode> callback) { validateDeviceCodeRequestInput(clientId, resource); return service.submit( new AcquireDeviceCodeCallable(this, clientId, resource, callback)); }
/** * Acquires security token from the authority using an device code previously received. * * @param deviceCode The device code result received from calling acquireDeviceCode. * @param callback optional callback object for non-blocking execution. * @return A {@link Future} object representing the {@link AuthenticationResult} of the call. * It contains AccessToken, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException thrown if authorization is pending or another error occurred. * If the errorCode of the exception is AdalErrorCode.AUTHORIZATION_PENDING, * the call needs to be retried until the AccessToken is returned. * DeviceCode.interval - The minimum amount of time in seconds that the client * SHOULD wait between polling requests to the token endpoin */ public Future<AuthenticationResult> acquireTokenByDeviceCode( final DeviceCode deviceCode, final AuthenticationCallback callback) throws AuthenticationException { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(deviceCode.getClientId())); this.validateDeviceCodeRequestInput(deviceCode, clientAuth, deviceCode.getResource()); final AdalDeviceCodeAuthorizationGrant deviceCodeGrant = new AdalDeviceCodeAuthorizationGrant(deviceCode, deviceCode.getResource()); return this.acquireToken(deviceCodeGrant, clientAuth, callback); }
/** * Acquires security token from the authority using an device code previously received. * * @param deviceCode The device code result received from calling acquireDeviceCode. * @param callback optional callback object for non-blocking execution. * @return A {@link Future} object representing the {@link AuthenticationResult} of the call. * It contains AccessToken, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException thrown if authorization is pending or another error occurred. * If the errorCode of the exception is AdalErrorCode.AUTHORIZATION_PENDING, * the call needs to be retried until the AccessToken is returned. * DeviceCode.interval - The minimum amount of time in seconds that the client * SHOULD wait between polling requests to the token endpoin */ public Future<AuthenticationResult> acquireTokenByDeviceCode( final DeviceCode deviceCode, final AuthenticationCallback callback) throws AuthenticationException { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(deviceCode.getClientId())); this.validateDeviceCodeRequestInput(deviceCode, clientAuth, deviceCode.getResource()); final AdalDeviceCodeAuthorizationGrant deviceCodeGrant = new AdalDeviceCodeAuthorizationGrant(deviceCode, deviceCode.getResource()); return this.acquireToken(deviceCodeGrant, clientAuth, callback); }