We keep getting this error. Can anyone point us in the right direction?
Token endpoint error: {“error_description”:“JWT is not valid”,“error”:“invalid_client”}
Stack: at Cis2AuthService.ExchangeCodeForTokenObject(String code) in d:\HostingSpace\istaffrota_UATNew\App_Code\Cis2AuthService.cs:line 69 at VisionIntel.IStaffRota.WebApp.cis2.Cis2Callback.Page_Load(Object sender, EventArgs e) in d:\HostingSpace\istaffrota_UATNew\cis2\Cis2Callback.aspx.cs:line 59
Assuming you are calling the CIS2 Auth token endpoint we would need more details of the request to find the error log entry. However, this is generally caused by invalid config on your side.
The is likely due to the JWKS endpoint is not valid, not accessible or returning the invalid keys - it has to be discoverable and visible over the internet. Check for bad characters, commas, etc in your JWKS file, ensure the right KID is being used and that the key is valid
Thanks for that. Firstly and most importantly, you have included passwords and secrets in the linked file - please replace those in your code and delete the zip file.
Secondly the issue is that the JWKS file appears to be UTF-8 and has a BOM (Byte Order Marker) at the start which is not recognised (0xef, 0xbb,0xbf) , please upload a vanilla text file without the BOM.
The location doesn’t matter, it is the content - it will work as expected when the BOM is removed from the start of the file. The above is still incorrect (there are 3 hidden characters in the actual file)
the latest file sent does not seem to have a BOM in it, is it not the fact that if it start with 7B, then it does not have a bom. developers are out for the day, but saved this file as UTF-8… Would this work?
but we still get this error. where could we go wrong please?
CIS2 Authentication
Returned state: ……
CIS2 Authentication Error:
Token endpoint error: {“error_description”:“JWT is not valid”,“error”:“invalid_client”}
Stack: at Cis2AuthService.ExchangeCodeForTokenObject(String code) in d:\HostingSpace\istaffrota_UATNew\App_Code\Cis2AuthService.cs:line 69 at VisionIntel.IStaffRota.WebApp.cis2.Cis2Callback.Page_Load(Object sender, EventArgs e) in d:\HostingSpace\istaffrota_UATNew\cis2\Cis2Callback.aspx.cs:line 59
The signature is invalid given the above key - You can use https://JWT.io to test your assertion value using the your public key in the JWKS file. When I place the current key and your last assertion (as of 8:12 this morning) it fails validation. I’d suspect the key used to sign the token is different to the public key. Note if you change the key value you need to change the kid in line with any rotation - We will cache the key for a period of time and only will only fetch it if we don’t recognise the kid
everything seems valid we are getting the same error, at some point we got this error: Token endpoint error: {“error_description”:“Invalid JWT audience”,“error”:“invalid_client”}
The audience is incorrect as the error implies - it has to exactly match our docs and implementation - which unfortunately means it needs the :443 adding to specify the port
It would appear the team has made some progress, but now we are getting this error try to redirect to the correct page. Any advice please?
CIS2 Authentication
Returned state: 396d7f9980654245a23ddc2410636e8dCookie state: [396d7f9980654245a23ddc2410636e8d]
CIS2 Authentication Error:
Authentication not recent.
Stack: at VisionIntel.IStaffRota.WebApp.cis2.Cis2Callback.Page_Load(Object sender, EventArgs e) in d:\HostingSpace\istaffrota_UATNew\cis2\Cis2Callback.aspx.cs:line 129
Hi Andre, that looks like your internal code so I can’t comment - given the error it looks like you are checking the auth_time - ensure your clocks are synced and you have a small grace period to allow for clock-skew - again please refer to the docs above for guidance
We seem to have resolved all CIS2 issues but we are struggling with a redirect issue, and it could be you have come across this with other companies. We are here at the last stage that says ‘display home page’, but it does not seem to recognise the user that is already logged in.
Source Error:
Line 177: //lblStatus.Text = currentUserId;
Line 178: lblStatus.Text = “Authentication successful. Redirecting…”; Line 179:string userId = Request.Cookies[“currentUserId”]?.Value;
Line 180:string companyId = Request.Cookies[“companyId”]?.Value;
Line 181:
Has anyone come across it and any ideas you could help us with please? here is our line of code:
I can’t comment on your internal code, but you appear to be trying to get the user ID, etc from a cookie? They are returned by CIS2 Auth within the ID_TOKEN - how you use them is an implementation issue for your developers - but I would suggest you aren’t capturing the information properly