Announcement Announcement Module
Collapse
No announcement yet.
auth.getAuthorizationRequest().getClientId() is null Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • auth.getAuthorizationRequest().getClientId() is null

    Below statement is giving me null. please help me what i am missing

    auth.getAuthorizationRequest().getClientId()


    auth is OAuth2Authentication

  • #2
    Where did you get the OAuth2Authentication from? It depends entirely on who actually created it, whether or not the client id is there.

    Comment


    • #3
      From my controller.. Here is sample code

      @RequestMapping(value = "/{" + CUSTOMER_ID + "}", method = RequestMethod.GET)
      @PreAuthorize("#oauth2.clientHasRole('ROLE_CLIENT' )")
      @ResponseBody
      public Customer getCustomer(@PathVariable(CUSTOMER_ID) String customerId, OAuth2Authentication auth) {



      And i am able to see the client in token store (I am using Spring InMemoryToken store)

      Comment


      • #4
        If you put an object in a controller method parameter and no extra declarations to tell what Spring to do it will just create a new instance from the default constructor, so that probably explains why it is not setting the client id. What did you need it for? Is this a request that is authenticated through the OAuth2 authentication processing filter? If so then the Spring Security context should have an instance of OAuth2Authentication in it (and you can get that in a controller method by asking for a Principal).

        Comment

        Working...
        X