use of com.okta.oidc.net.request.RefreshTokenRequest in project okta-oidc-android by okta.
the class SyncSessionClientImplTest method refreshTokenRequestFailure.
@Test
public void refreshTokenRequestFailure() throws InterruptedException, JSONException, AuthorizationException, OktaRepository.EncryptionException {
mOktaState.save(mTokenResponse);
mExpectedEx.expect(AuthorizationException.class);
mEndPoint.enqueueReturnInvalidClient();
RefreshTokenRequest request = mSyncSessionClientImpl.refreshTokenRequest(mOktaState.getProviderConfiguration(), mTokenResponse);
TokenResponse response = request.executeRequest(mHttpClient);
assertNull(response);
}
use of com.okta.oidc.net.request.RefreshTokenRequest in project okta-oidc-android by okta.
the class SyncSessionClientImpl method refreshToken.
@Override
public Tokens refreshToken() throws AuthorizationException {
try {
RefreshTokenRequest request = refreshTokenRequest(mOktaState.getProviderConfiguration(), mOktaState.getTokenResponse());
mCurrentRequest.set(new WeakReference<>(request));
TokenResponse tokenResponse = request.executeRequest(mHttpClient);
mOktaState.save(tokenResponse);
return new Tokens(tokenResponse);
} catch (OktaRepository.EncryptionException e) {
throw AuthorizationException.EncryptionErrors.byEncryptionException(e);
}
}
use of com.okta.oidc.net.request.RefreshTokenRequest in project okta-oidc-android by okta.
the class SyncSessionClientImplTest method refreshTokenRequest.
@Test
public void refreshTokenRequest() throws InterruptedException, JSONException, AuthorizationException, OktaRepository.EncryptionException {
mOktaState.save(mTokenResponse);
RefreshTokenRequest request = mSyncSessionClientImpl.refreshTokenRequest(mOktaState.getProviderConfiguration(), mTokenResponse);
String nonce = CodeVerifierUtil.generateRandomState();
String jws = TestValues.getJwt(mEndPoint.getUrl(), nonce, mConfig.getClientId());
mEndPoint.enqueueTokenSuccess(jws);
TokenResponse response = request.executeRequest(mHttpClient);
assertNotNull(response);
TokenResponse original = mGson.fromJson(String.format(TOKEN_SUCCESS, jws), TokenResponse.class);
assertEquals(original.getIdToken(), response.getIdToken());
assertEquals(original.getRefreshToken(), response.getRefreshToken());
assertEquals(original.getIdToken(), response.getIdToken());
}
Aggregations