app_metadata
:
app_metadata
instead of user_metadata
because they should not be directly changeable by the user.
user_metadata
:
app_metadata
, the user can easily and readily change those stored in user_metadata
.
We can let the user change their displayName
, which is the name the user sees upon logging in and is displayed to other users of the app.
To display the user’s chosen identifier whenever they log in, we use a rule to get the user.user_metadata
value.
displayName
:
user_metadata
field:
{yourAccessToken}
with a Management API Access Token.
playlist_editor
as a value in the roles
array in app_metadata
.
app_metadata
field and assigns the roles
array to a field in the user object so it can be accessed without calling app_metadata
on the application. The scope
parameter can then specify roles
upon the user logging in without including everything in app_metadata
in the user object:
playlist_editor
is in the roles
array stored in the user’s app_metadata
, the user will be welcomed as an EDITOR after signing in:
user_id
and it’s the sub-property of the idTokenPayload
object in an authResult
. Here is a sample row from the songs
table in our database:
song_id | songname | user_id |
---|---|---|
1 | Number One Hit | google-oauth2 |
GET
request to /secured/getFavGenre
, the API calls the queryGenre()
function, which queries the database for and responds with the user’s favorite genre.
buildAPIRequest()
takes the path and HTTP method of the request as parameters and builds a request using the base URL of our Node.js API that’s hosted on Heroku.
In the Application, the getGenre()
function makes a request to the API and changes the app’s interface to display the request response to /genres/getFav
. The backend retrieves the required data for this action using the queryGenre()
function and returns the results to the Application: