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

3.x authorizations are applied to operation, not client #971

Closed
fehguy opened this issue Mar 22, 2017 · 9 comments
Closed

3.x authorizations are applied to operation, not client #971

fehguy opened this issue Mar 22, 2017 · 9 comments

Comments

@fehguy
Copy link
Contributor

fehguy commented Mar 22, 2017

This was an unintended change from the 2.x series for swagger-js, we should be able to authorize a client and have it apply them to operations as needed. Instead, we have to apply them to each operation, every time.

@ponelat
Copy link
Member

ponelat commented Mar 29, 2017

see: swagger-api/swagger-ui#2793

@webron
Copy link
Contributor

webron commented Apr 19, 2017

@ponelat does #975 cover this and the issue can be closed or is something else needed?

@ponelat
Copy link
Member

ponelat commented Apr 19, 2017

Yup that solves this issue. It doesn't solve the issue of adding auth to fetching the spec. That's tracked elsewhere.

@webron webron closed this as completed Apr 19, 2017
@jasongonzales23
Copy link

Hi, I got here from the FAQs, and it looks like you've changed how authorizations worked. If that is correct, perhaps we should document this. Happy to help, BTW, but perhaps someone with more experience with the project can do it better than I.

@komasoftware
Copy link

I have a Swagger 2.0 spec with following security definition

securityDefinitions:
    jwt:
        type: apiKey
        name: Authorization
        in: header

But I have a hard time getting the swagger-js 3.0 client to pass the credentials.
This is what I am doing

            let authorizations = {
                jwt: { token: { access_token: "jwtvalue goes here" } }
            };
            return new SwaggerClient({
                url: 'specURL goes here',
                authorizations: authorizations
            })
                .then(client => {
               .....

Can I even use the swagger-js 3.0 client against a swagger 2.0 spec ?
The only documentation I could find was in the migration doc ...

@vukee
Copy link

vukee commented Dec 14, 2018

Same issue here. I can add whatever I want into 'authorizations', nothing is passed with the request.

Is there somewhere a full documentation for swagger-js? Or some examples how to use authorizations? Would be really helpful.

@devth
Copy link

devth commented Jan 5, 2019

It's still not clear to me how to add per-request operations. All the examples in the index-authorizations tests seem to be global to the client.

@syntax-e
Copy link

From the documentation I'm having a pretty tough time understanding how to add the following header to my requests:
authorization: bearer {token}

Any tips?

@gpineda-dev
Copy link

gpineda-dev commented May 15, 2019

It's still not clear to me how to add per-request operations. All the examples in the index-authorizations tests seem to be global to the client.

I encounter the same issue but i solved it with

Swagger(SWAGGER_ENDPOINT,{
    authorizations: {
        accessTokenAuth: `Bearer ${SWAGGER_TOKEN}`
        //accessTokenAuth: {token: {access_token: SWAGGER_TOKEN}}
    }
})

and it works but not very clean
I hope it might help you

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

No branches or pull requests

9 participants