Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization: Bearer token is not present in header #27

Open
eriCCsan opened this issue Sep 8, 2024 · 0 comments
Open

Authorization: Bearer token is not present in header #27

eriCCsan opened this issue Sep 8, 2024 · 0 comments

Comments

@eriCCsan
Copy link

eriCCsan commented Sep 8, 2024

Hi, I have been using this plugin. I figured it all out myself, but now I am stuck.
I just want to send a bearer token in the header within the api request. but the token is not being sent.
I have successfully logged in my Keycloak tells me that a sessions has been created.

After a little research, I found something that might be missing here. The requestInterceptor.
Maybe I'm doing this completely wrong? I'm using the password flow as it doesn't need to be that secure as it's just for testing.

Any advice would be appreciated.

<script>
    window.onload = function() {
        const ui = SwaggerUIBundle({
            url: "http://localhost:8000/v3/api-docs",
            dom_id: '#swagger-ui',
            deepLinking: true,
            presets: [
                SwaggerUIBundle.presets.apis,
                SwaggerUIStandalonePreset
            ],
            plugins: [
                SwaggerUIBundle.plugins.DownloadUrl
            ],
            oauth2RedirectUrl: "http://localhost:8000/oauth2-redirect.html",
            requestInterceptor: function(request) {
                if (window.authorizedAccessToken) {
                    request.headers['Authorization'] = "Bearer " + window.authorizedAccessToken;
                }
                return request;
            }
        })
    }
</script>

EDIT:
After a while I found out that Swagger does not save the token in the browser and therefore cannot be used. But how do you save the token in the browser with this plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant