Search code examples
javaspring-bootauth0

Auth0 spring Boot implementation userId has |


i currently add auth0 to my Spring Boot api, to handle the security. Now I face the problem, that auth0 is generating userId's with the "|" in it. In my Spring boot api i have some enpoints that are taking the user id as a pathVariable like "/user/{userId}". Those request now getting a error bc. of the invalid character | in the header.

Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in the request target [/api/v1/user/service/google-oauth2|114309183689720156358 ]. The valid characters are defined in RFC 7230 and RFC 3986

How would you solve this problem?


Solution

  • You could encode it to \u007c before creating the url.

    This approach will also help if your users have odd characters like æøåûü in the user ids