diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 836446fb0..aef9d41d7 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -139,7 +139,21 @@ "password": "Password", "token": "Token", "type": "Authorization Type", - "username": "Username" + "username": "Username", + "oauth": { + "token_generation_oidc_discovery_failed": "Failure on token generation: OpenID Connect Discovery Failed", + "something_went_wrong_on_token_generation": "Something went wrong on token generation", + "redirect_auth_server_returned_error": "Auth Server returned an error state", + "redirect_no_auth_code": "No Authorization Code present in the redirect", + "redirect_invalid_state": "Invalid State value present in the redirect", + "redirect_no_token_endpoint": "No Token Endpoint Defined", + "redirect_no_client_id": "No Client ID defined", + "redirect_no_client_secret": "No Client Secret Defined", + "redirect_no_code_verifier": "No Code Verifier Defined", + "redirect_auth_token_request_failed": "Request to get the auth token failed", + "redirect_auth_token_request_invalid_response": "Invalid Response from the Token Endpoint when requesting for an auth token", + "something_went_wrong_on_oauth_redirect": "Something went wrong during OAuth Redirect" + } }, "collection": { "created": "Collection created", diff --git a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue b/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue index b288f6afb..fbd157170 100644 --- a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue +++ b/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue @@ -78,6 +78,15 @@ const clientSecret = pluckRef(auth, "clientSecret" as any) const scope = pluckRef(auth, "scope") +function translateTokenRequestError(error: string) { + switch (error) { + case "OIDC_DISCOVERY_FAILED": + return t("authorization.oauth.token_generation_oidc_discovery_failed") + default: + return t("authorization.oauth.something_went_wrong_on_token_generation") + } +} + const handleAccessTokenRequest = async () => { if ( oidcDiscoveryURL.value === "" && @@ -102,7 +111,7 @@ const handleAccessTokenRequest = async () => { const res = await tokenRequest(tokenReqParams) if (res && E.isLeft(res)) { - toast.error(res.left) + toast.error(translateTokenRequestError(res.left)) } } catch (e) { toast.error(`${e}`) diff --git a/packages/hoppscotch-common/src/pages/oauth.vue b/packages/hoppscotch-common/src/pages/oauth.vue index 063c3ef4e..b8d600685 100644 --- a/packages/hoppscotch-common/src/pages/oauth.vue +++ b/packages/hoppscotch-common/src/pages/oauth.vue @@ -7,6 +7,7 @@