question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong parameters for spring-security "/oaut/token" Endpoint

See original GitHub issue

I’m not sure where is the problem but springfox generate this swagger.json (v2/api-docs) for spring-security /oaut/token endpoint:

      "post":{
            "tags":[
               "token-endpoint"
            ],
            "summary":"postAccessToken",
            "operationId":"postAccessTokenUsingPOST_2",
            "consumes":[
               "application/json"
            ],
            "produces":[
               "*/*"
            ],
            "parameters":[
               {
                  "name":"parameters",
                  "in":"query",
                  "description":"parameters",
                  "required":true,
                  "items":{
                     "type":"object",
                     "additionalProperties":{
                        "type":"string"
                     }
                  }
               }
            ],

I’s have required “parameters” in query but its need to be in body this is the right curl: curl -iv -X POST --header "Accept:application/json" --header "Content-Type: application/x-www-form-urlencoded" -u fooClientIdPassword:secret "http://localhost:8081/oauth/token" -d "grant_type=password&client_id=fooClientIdPassword&username=john&password=123" Can I change or override securityDefinitions for spring-security Endpoints ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sytolkcommented, Jun 16, 2018

I have add this too:

@Bean
    public OperationModelsProviderPlugin operationModelsProviderPlugin() {
        return new OperationModelsProviderPlugin() {
            @Override
            public void apply(RequestMappingContext context) {
                if ("postAccessToken".equals(context.getName())) {                    
                       context.getDocumentationContext().getConsumes()
                       .add(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
                }
            }          

            @Override
            public boolean supports(DocumentationType delimiter) {
                return SwaggerPluginSupport.pluginDoesApply(delimiter);
            }
        };
    }

and on swagger-js-codegen side: if(form.parameters != undefined) form = form.parameters; It works but its look like ugly fix for me. Let me know if you have better fix for this

0reactions
liuweiGLcommented, Sep 17, 2020

The plugin’s apply function is executed, but it doesn’t seem to matter.

And no errors occur.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Oauth2 Error "Token not found in request parameters ...
I have resolved this problem after changing the order of WebSecurityConfigurerAdapter higher than the resource server.
Read more >
Error handling for Spring Security Resource Server - Microflash
In this post, we'll discuss how to customize error handling for a REST API protected with OAuth 2 using Spring Security Resource Server....
Read more >
OAuth2ParameterNames (spring-security-docs 6.0.0 API)
Standard and custom (non-standard) parameter names defined in the OAuth Parameters Registry and used by the authorization endpoint, token endpoint and token ......
Read more >
Possible Errors - OAuth 2.0 Simplified
If one or more parameters are invalid, such as a required value is missing, or the response_type parameter is wrong, the server will...
Read more >
spring-projects/spring-security-oauth - Gitter
@matin-reza Please change your configuration to also have .anyRequest().authenticated() . Also, you can change your method parameter to OAuth2Authentication ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found