Auth0 Home Blog Docs

Pre/Post registration hook: How to retrieve the audience?

audience
post-user-registrati
registration
pre-user-registratio

#1

I’d like to know which audience users are trying to access in order to show them a personalized email verification message.

How can I retrieve the audience in a pre/post registration hook?

Apparently, adding the info to the user_metadata within the client (either native Android or iOS) is very difficult.


#2

To my knowledge there’s no way to access audience within those hooks. I know that client application information, like the client identifier, was left out in an intentional way because there should be no dependency on a piece of information that is purely an OAuth2 artifact. However, with audience and purely as a personal opinion it could be argued it’s more debatable because the purpose is more to know the initial service at which the end-user registered for email customization purposes. Having said that, even if I find it more debatable the fact is that it’s currently not available.

My recommendation would be to, as you mentioned, leverage user metadata as the way to signal the entry point of the user into your ecosystem; so if you have two services that actually allow the reuse of the same identity, a field in the user metadata would allow you know where the user first landed and in such way provide a more customized welcome email.

Focusing on that approach I have to confess I never done it in iOS, but for Android you can check this existing answer on a question related to this subject; the OP on that question mentions that iOS allows to pass user metadata directly in the createUser call so it may even be simpler (less lines of code) then in Android.


#3

Thank you. The createUser method could work. As I’m using the Lock project at the moment, this means more code to be removed & replaced.


#4