Hi,
you could map sso
field to custom user field and use it like this
const user = api.getCurrentUser()
console.log(user.custom_fields.external_id)
How to map sso field to custom user field, check here: Official Single-Sign-On for Discourse (sso)
You need to make that custom field public in the settings in order to access it in the theme.