I am trying to get an access token but am receiving {“error”:“invalid_grant”,“error_description”:“Code not valid”}. Here are my steps:
-
I put into the browser the following:
(http://localhost:8080/realms/testrealm/protocol/openid-connect/auth?client_id=testclient&redirect_uri=http://localhost:3001&response_type=code&scope=openid&state=abcd12345)
-
I receive:
(http://localhost:3001/?state=abcd12345&session_state=85ef9497-f021-435e-8f52-99b3d51c60b2&code=1968778b-8c73-4b47-ad97-a195f2bfed71.85ef9497-f021-435e-8f52-99b3d51c60b2.7637e258-5e11-4ba6-b9eb-e2de5341d1e3)
-
I then go to a terminal and enter:
curl -X POST 'http://localhost:8080/realms/testrealm/protocol/openid-connect/token' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=authorization_code' --data-urlencode 'client_id=testclient' --data-urlencode 'code=1968778b-8c73-4b47-ad97-a195f2bfed71.85ef9497-f021-435e-8f52-99b3d51c60b2.7637e258-5e11-4ba6-b9eb-e2de5341d1e3' --data-urlencode 'redirect_uri=http://localhost:3001'
-
I receive:
{"error":"invalid_grant","error_description":"Code not valid"}
Would someone be able to assist me with this?