Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(auth): add response interceptor to prompt authorization on 401 s…#10441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dmytro-arkhypenko wants to merge1 commit intoswagger-api:master
base:master
Choose a base branch
Loading
fromdmytro-arkhypenko:users/dmytro-arkhypenko

Conversation

dmytro-arkhypenko
Copy link

@dmytro-arkhypenkodmytro-arkhypenko commentedMay 5, 2025
edited
Loading

🟢 Swagger UI: Auto-login Prompt on 401 Response

Description

This PR introduces a new configuration option:autoPromptAuthOn401, which, when enabled, will automatically trigger the "Authorize" modal whenever an API call returns a401 Unauthorized response in the Swagger UI "Try it out" flow.

SwaggerUI({url:"/swagger.json",dom_id:"#swagger-ui",autoPromptAuthOn401:true})

This provides a smoother user experience for secured APIs, especially in cases where session expiration is common or initial authorization is missing.


Motivation and Context

Many secured APIs require users to authenticate before accessing most endpoints. Currently, when a401 is returned, the UI does not give feedback other than showing the raw error, which can confuse users. With this change:

  • Users are immediately prompted to log in.
  • This reduces friction, especially for new or unauthenticated users.

Fixes#10438


How Has This Been Tested?

  • Verified manual requests via "Try it out" to protected endpoints.
  • Confirmed that the modal is triggered only on 401 responses.
  • Ensured that the change does not affect normal UI behavior for public endpoints.
  • Tested fallback behavior when no authorize button is available.

Screenshots

(Not included in this PR)


Checklist

My PR contains...

  • No code changes
  • Dependency changes
  • Bug fixes
  • Improvements
  • Features

My changes...

  • are breaking changes to a public API
  • are breaking changes to a private API
  • are breaking changes to a developer API
  • are not breaking changes

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Show Swagger UI logon window when API requests came back as 401
1 participant
@dmytro-arkhypenko

[8]ページ先頭

©2009-2025 Movatter.jp