DEV Community

Discussion on: Securing your express/Node.js API with Firebase auth

Collapse
 
seanmclem profile image
Seanmclem • Edited

what is "setUserClaim"? As far as I can tell it only exists in this article.

Collapse
 
emeka profile image
Nwakwoke Patrick Nnaemeka

For assigning roles to users. You can read more on the firebase docs
firebase.google.com/docs/auth/admi...

Collapse
 
seanmclem profile image
Seanmclem

Seems they use setCustomUserClaims, not setUserClaim?

Thread Thread
 
emeka profile image
Nwakwoke Patrick Nnaemeka

Thanks for pointing this out. Corrected the typo.

Thread Thread
 
seanmclem profile image
Seanmclem

Thanks, also it seems like on your frontend code that firebase.initialize(config); would now be initializeApp instead of initialize;
For a WebApp atleast.

Thread Thread
 
emeka profile image
Nwakwoke Patrick Nnaemeka

Thanks for pointing that out. Will correct it

Thread Thread
 
seanmclem profile image
Seanmclem • Edited

Sorry but,

When you do:
return axios.get('https://your-api-url/articles', {headers:
authorization: 'Bearer '+ token})

You missed a bracket or two, and have not put authorization into another object inside headers. It should probably be

return axios.get('https://your-api-url/articles', {headers: {
authorization: 'Bearer '+ token}})

Thread Thread
 
emeka profile image
Nwakwoke Patrick Nnaemeka

Thanks again

Thread Thread
 
seanmclem profile image
Seanmclem • Edited

also, auth is a function
auth().setCustomUserClaims
🙃