Spring Boot does not recognize the controller when a request with parameters is sent

Asked

Viewed 339 times

0

Spring Boot does not recognize my controller if I submit more parameters in the request. For example:

If I send a normal GET request spring boot recognizes my controller: http://localhost/idp/oauth/123/authorize

If I send a GET request with more parameters in the query spring boot does not recognize my controller: http://localhost/idp/oauth/123/authorize?scope=public_profile

I need to receive the request exactly according to the second example (with the Scope parameter). spring does not recognize the controller and redirects to /error.

code:

@Controller
@RequestMapping("/idp/oauth")
public class OAuthController {

    @RequestMapping(value = "/{clientId}/authorize", method = RequestMethod.GET)
    public String authorizeGet(
            HttpServletRequest request, 
            HttpServletResponse response, 
            @PathVariable String clientId,
            Model model) {
            // ...
    }

    @RequestMapping(value = "/{clientId}/authorize", method = RequestMethod.POST)
    public String authorizePost(
            HttpServletRequest request, 
            HttpServletResponse response, 
            @PathVariable String clientId,
            Model model) {
            // ...
    }
}
  • You are on Stackoverflow in English, translate your question accordingly

  • Corrected, thank you very much!

3 answers

1

Good Morning,

From what I understand, your method lacks an attribute:

(@RequestParam(value="scope", defaultValue="public_profile") String scope)

Dai yes, you can do this query in the URL.

  • Even adding@Requestparam(name = "Scope") String Scope 'does not work :(. Keeps redirecting to error.

  • what mistake is giving you?

  • I have an intruder who intercepts all the requisitions. Then I see the requested URL 'System.out.println(request.getRequestURL().toString();' and it takes http://localhost/error

  • take a look at your browser or put it here, I have uploaded your code here without Third Party and rolled this call : localhost:8380/idp/oauth/200/Authorize? Scope=public_profile

0

Missing you add @Queryparam in the parameters you are passing via Query. What is the case with "? Scope=public_profile"

0

    @GetMapping(value = "/{clientId}/authorize")
    public ResponseEntity<String> authorizeGet(
                @RequestParam(value = "scope", defaultValue = "public_profile") String scope) {
    // ...
        }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.