Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions android/src/main/java/com/rnappauth/RNAppAuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void prefetchConfiguration(
isPrefetched = true;
fetchConfigurationLatch.countDown();
} catch (Exception e) {
promise.reject("RNAppAuth Error", "Failed to convert serviceConfiguration", e);
promise.reject("configuration_error", "Failed to convert serviceConfiguration", e);
}
} else if (mServiceConfiguration.get() == null) {
final Uri issuerUri = Uri.parse(issuer);
Expand All @@ -107,7 +107,7 @@ public void onFetchConfigurationCompleted(
@Nullable AuthorizationServiceConfiguration fetchedConfiguration,
@Nullable AuthorizationException ex) {
if (ex != null) {
promise.reject("RNAppAuth Error", "Failed to fetch configuration", ex);
promise.reject("service_configuration_fetch_error", "Failed to fetch configuration", ex);
return;
}
mServiceConfiguration.set(fetchedConfiguration);
Expand All @@ -126,7 +126,7 @@ public void onFetchConfigurationCompleted(
fetchConfigurationLatch.await();
promise.resolve(isPrefetched);
} catch (Exception e) {
promise.reject("RNAppAuth Error", "Failed to await fetch configuration", e);
promise.reject("service_configuration_fetch_error", "Failed to await fetch configuration", e);
}
}

Expand Down Expand Up @@ -175,7 +175,7 @@ public void authorize(
additionalParametersMap
);
} catch (Exception e) {
promise.reject("Failed to authenticate", e.getMessage());
promise.reject("authentication_failed", e.getMessage());
}
} else {
final Uri issuerUri = Uri.parse(issuer);
Expand All @@ -186,7 +186,7 @@ public void onFetchConfigurationCompleted(
@Nullable AuthorizationServiceConfiguration fetchedConfiguration,
@Nullable AuthorizationException ex) {
if (ex != null) {
promise.reject("Failed to fetch configuration", getErrorMessage(ex));
promise.reject("service_configuration_fetch_error", getErrorMessage(ex));
return;
}

Expand Down Expand Up @@ -257,7 +257,7 @@ public void refresh(
promise
);
} catch (Exception e) {
promise.reject("Failed to refresh token", e.getMessage());
promise.reject("token_refresh_failed", e.getMessage());
}
} else {
final Uri issuerUri = Uri.parse(issuer);
Expand All @@ -268,7 +268,7 @@ public void onFetchConfigurationCompleted(
@Nullable AuthorizationServiceConfiguration fetchedConfiguration,
@Nullable AuthorizationException ex) {
if (ex != null) {
promise.reject("Failed to fetch configuration", getErrorMessage(ex));
promise.reject("service_configuration_fetch_error", getErrorMessage(ex));
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be service_configuration_fetch_error right?

}

Expand Down Expand Up @@ -300,14 +300,14 @@ public void onFetchConfigurationCompleted(
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if (data == null) {
promise.reject("Failed to authenticate", "Data intent is null" );
promise.reject("authentication_error", "Data intent is null" );
return;
}

final AuthorizationResponse response = AuthorizationResponse.fromIntent(data);
AuthorizationException exception = AuthorizationException.fromIntent(data);
if (exception != null) {
promise.reject("Failed to authenticate", getErrorMessage(exception));
promise.reject("authentication_error", getErrorMessage(exception));
return;
}

Expand All @@ -329,7 +329,7 @@ public void onTokenRequestCompleted(
WritableMap map = TokenResponseFactory.tokenResponseToMap(resp, response);
authorizePromise.resolve(map);
} else {
promise.reject("Failed exchange token", getErrorMessage(ex));
promise.reject("token_exchange_failed", getErrorMessage(ex));
}
}
};
Expand Down Expand Up @@ -468,7 +468,7 @@ public void onTokenRequestCompleted(@Nullable TokenResponse response, @Nullable
WritableMap map = TokenResponseFactory.tokenResponseToMap(response);
promise.resolve(map);
} else {
promise.reject("Failed to refresh token", getErrorMessage(ex));
promise.reject("token_refresh_failed", getErrorMessage(ex));
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions ios/RNAppAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (dispatch_queue_t)methodQueue
[OIDAuthorizationService discoverServiceConfigurationForIssuer:[NSURL URLWithString:issuer]
completion:^(OIDServiceConfiguration *_Nullable configuration, NSError *_Nullable error) {
if (!configuration) {
reject(@"RNAppAuth Error", [error localizedDescription], error);
reject(@"service_configuration_fetch_error", [error localizedDescription], error);
return;
}
[self authorizeWithConfiguration: configuration
Expand Down Expand Up @@ -110,7 +110,7 @@ - (dispatch_queue_t)methodQueue
[OIDAuthorizationService discoverServiceConfigurationForIssuer:[NSURL URLWithString:issuer]
completion:^(OIDServiceConfiguration *_Nullable configuration, NSError *_Nullable error) {
if (!configuration) {
reject(@"RNAppAuth Error", [error localizedDescription], error);
reject(@"service_configuration_fetch_error", [error localizedDescription], error);
return;
}
[self refreshWithConfiguration: configuration
Expand Down Expand Up @@ -215,7 +215,7 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
resolve([self formatResponse:authState.lastTokenResponse
withAuthResponse:authState.lastAuthorizationResponse]);
} else {
reject(@"RNAppAuth Error", [error localizedDescription], error);
reject(@"authentication_failed", [error localizedDescription], error);
}
}]; // end [OIDAuthState authStateByPresentingAuthorizationRequest:request
}
Expand Down Expand Up @@ -252,7 +252,7 @@ - (void)refreshWithConfiguration: (OIDServiceConfiguration *)configuration
if (response) {
resolve([self formatResponse:response]);
} else {
reject(@"RNAppAuth Error", [error localizedDescription], error);
reject(@"token_refresh_failed", [error localizedDescription], error);
}
}];
}
Expand Down