• Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login
FusionAuth
  • Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login

PKCE Verification Fails

Scheduled Pinned Locked Moved
General Discussion
3
4
638
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    rmachorro
    last edited by 29 Sept 2022, 19:14

    I have a pre-existing FusionAuth integrated application that uses Authorization Code successfully. For safety reasons I'm adding support for PKCE.

    I've added code_challenge and code_challenge_method to the authorize url, so it looks like this:

    https://.../oauth2/authorize?client_id=...&tenantId=...&redirect_uri=.../authcallback&response_type=code&scope=openid&state=...&code_challenge=...&code_challenge_method=S256
    

    Upon response to callback, the code is then sent back to FusionAuth in the Token request, adding the code_verifier:

    POST /oauth2/token HTTP/1.1
    Content-Type: application/x-www-form-urlencoded
    Host: ...
    Connection: close
    Content-Length: 241
    
    client_id=...&redirect_uri=...%3A3000%2Fauthcallback&code=...&code_verifier=...&grant_type=authorization_code
    

    The response is a 400 Bad Request with the following body:

    {"error":"invalid_request","error_description":"Invalid Authorization Code","error_reason":"auth_code_not_found"}
    
    D 1 Reply Last reply 24 Oct 2022, 21:14 Reply Quote 0
    • D
      dan @rmachorro
      last edited by 24 Oct 2022, 21:14

      @rmachorro What version of FusionAuth are you using? At first glance that appears to be the right way to do it.

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • J
        julien.sarriot
        last edited by 13 Nov 2022, 10:36

        @dan I have the same error, it seem that fusionauth just throw the same error when:

        • authorization code is invalid
        • code_verifier is invalid (good format but not corresponding to code_challenge)

        When I look at logs on fusionauth interface, I see good errors but not on http response.
        (I'm using 1.40.1)

        D 1 Reply Last reply 10 Dec 2022, 17:21 Reply Quote 0
        • D
          dan @julien.sarriot
          last edited by 10 Dec 2022, 17:21

          @julien-sarriot What does turning on the debug log do? https://fusionauth.io/docs/v1/tech/admin-guide/troubleshooting#enabling-debugging has instructions on how to do that and where to look after (in the event log).

          Please share that info here.

          --
          FusionAuth - Auth for devs, built by devs.
          https://fusionauth.io

          1 Reply Last reply Reply Quote 0
          • First post
            Last post