Welcome @jagaudin !
There’s no requirement that the primary key of the User model be an integer. You could create a User model where the username is the primary key. In that case, you could end up with non-url-safe characters in that primary key, which would make the constructed url invalid.
By base64 encoding that primary key, you know that what you’re using will create a valid url.