# Configuring Keycloak with OAuth2 and PKCE (login, register page not found)

**URL:** <https://forum.keycloak.org/t/configuring-keycloak-with-oauth2-and-pkce-login-register-page-not-found/23551>\
**Category:** Configuring the server\
**Tags:** authentication\
**Created:** [December 2, 2023, 10:14pm UTC](https://forum.keycloak.org/t/configuring-keycloak-with-oauth2-and-pkce-login-register-page-not-found/23551 "2023-12-02T22:14:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![angelopauli](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/angelopauli/32/9378_2.png) [@angelopauli](https://forum.keycloak.org/u/angelopauli)\
**Post date:** [December 2, 2023, 10:14pm UTC](https://forum.keycloak.org/t/configuring-keycloak-with-oauth2-and-pkce-login-register-page-not-found/23551/1 "2023-12-02T22:14:37Z")

</div>

Hello Everyone,

I am trying to configure my Keycloak server for OAuth2 with PKCE.

I have followed various tutorials and I followed these steps:

1. Create Realm ( test )
2. Create Client (test-client )
3. Set Client Authentication OFF → public
4. Choose Standard Flow
5. Set Redirect URI ([http://localhost:4200](http://localhost:4200))
6. Set Proof Key for Code Exchange Code Challenge Method → S256
7. Enable Register Flow in Realm Settings

Now I try to access my register page with a URL I am creating in a small script (python):

```auto
import base64
import hashlib
import os

def generate_code_challenge():
    # Generate a random code_verifier
    code_verifier = base64.urlsafe_b64encode(os.urandom(40)).decode('utf-8').replace('=', '')
    
    # Create a code_challenge based on the code_verifier
    code_challenge = hashlib.sha256(code_verifier.encode('utf-8')).digest()
    code_challenge = base64.urlsafe_b64encode(code_challenge).decode('utf-8').replace('=', '')
    
    return code_challenge

code_challenge = generate_code_challenge()

auth_url = (
    "http://localhost:8080/auth/realms/test/protocol/openid-connect/auth?"
    "client_id=test-client&"
    "response_type=code&"
    "scope=openid&"
    "redirect_uri=http://localhost:4200&"
    f"code_challenge={code_challenge}&"
    "code_challenge_method=S256"
)

register_url = (
    "http://localhost:8080/auth/realms/test/protocol/openid-connect/registrations?"
    "client_id=test-client&"
    "response_type=code&"
    "scope=openid&"
    "redirect_uri=http://localhost:4200&"
    f"code_challenge={code_challenge}&"
    "code_challenge_method=S256"
)

print(auth_url)
print(register_url)

```

I get the following urls:

When I try to enter them I get a Page not found. This worked in an earlier version I have used before 17.0.0.

I am using version 23.0.1 now.

Thank you in advance.

Regards,  
Angelo from Germany

---

<div class="post-metadata">

**Author:** ![angelopauli](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/angelopauli/32/9378_2.png) [@angelopauli](https://forum.keycloak.org/u/angelopauli)\
**Post date:** [December 3, 2023, 4:47pm UTC](https://forum.keycloak.org/t/configuring-keycloak-with-oauth2-and-pkce-login-register-page-not-found/23551/2 "2023-12-03T16:47:35Z")

</div>

Hello Everyone,

the issue is resolved with removing the first /auth

So [http://localhost:8080/realms/](http://localhost:8080/realms/)…
