fix: report a rejected auth key accurately on login - #302
Merged
Conversation
`auth login --auth-key <invalid>` reported "Unauthorized access." while an unreachable server reported "Invalid API key provided." The two conditions were inverted, and neither message told the user what to do next. - Key the login prompt off `ServiceErrorCode.UnAuthorized` rather than comparing the `NetworkError` singleton by reference, so a rejected key is named as such and connection failures report themselves. Comparing by code also survives factory-built errors, which an identity check silently stops matching. - Build that message from `ServiceError.unauthorizedWithHint` so the login / `--auth-key` guidance is worded identically to every other auth failure. - Reuse the same hint for the logged-out `auth status` message. - Reword the shared 401 fallback to "Authorization has been denied for this request." Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MuhammadRafay1
requested review from
Shield-Jaguar,
aliasghar98 and
saeedjamshaid
as code owners
July 30, 2026 10:35
mehnoorsiddiqui
approved these changes
Jul 30, 2026
The hint told users to pass --auth-key to whichever command hit the 401, but most of them don't declare that flag: `auth status` and `portal toc new` reject it outright. Name `apimatic auth login --auth-key` instead, so the remedy is valid wherever the message surfaces, and spell out that a bare `auth login` authenticates via the browser. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR fixes the gaps identified by QA here: https://github.com/apimatic/apimatic-io/issues/2180#issuecomment-5127202974
The error messaging is now consistent accross whole CLI
Some more Gaps I identified are also fixed
Details below:
Gaps closed