Hello!
I am using Auth0 to login with my custom DB and I am using FB as provider.
I want to save all the coming data of the user after he logged . Now I can do that using Rules
I save the data of the user in another database because I do not want to affect the data of Auth0 but the json is very weird with strange fields $t , $v for example:
"age_range": {
"$t": 3,
"$v": {
"min": {
"$t": 16,
"$v": 21
}
}
As you can see it is very difficult to read and get the results I know depending of the provider the profile could be different.
I could see using Auth0 API I can get a normalized User Profile and all the data from another providers in a friendly way to read.
I would like to know if there is a easier way to save this data with the same structure of User Profile(easy way to read) in my database maybe getting the profile user data from the Auth0 API using a rule.
Thank you for your help!
The age range coming from Facebook would be in a format like age_range: { min: 21 }
so the format you mention seems to be a translation from the original format to a different one where each property is expanded into $t
and $v
where $v
likely represents the original value and $t
possibly some metadata information.
This indicates that root cause of the issue is likely how you to store or read data from the database. doing a Google search suggests that you may get a format similar to that one if you’re using a Mongo library when talking to DocumentDB.
If you’re indeed talking to DocumentDB I would recommend you to try the specific SDK instead of trying to leverage the Mongo API compatibility. You should be able to use the DocumentDB Node.js SDK from a rule, in particular, with something like this:
var documentdb = require('documentdb@1.5.1');
It’s not the latest version, but it may resolve your situation.
Thank you for your answer!
Sorry but I am a beginner using auth0 I need to learn many things.
I did some research about this problem and now I can see the json that I want to save as document is invalid.
here is the json that I want to save I got this directly from the user in the rule(I mean I am saving the object user from the rule)
{ _id: '507fe250ba35a09cf6d39d027f75b10a',
email: 'test1@outlook.com',
email_verified: false,
clientID: 'gi1FcFBUSEX7c6srmZbgcR3m_IViva2F',
updated_at: '2017-06-21T16:58:51.589Z',
name: 'test1@outlook.com',
picture: 'xxx',
user_id: 'xxx',
nickname: 'test1',
user_metadata:
global_client_id: 'gi1FcFBUSEX7c6srmZbgcR3m_IViva2F',
persistent: {} }
As you can see the json is using simple quote and the properties does not have double double quotes.
maybe this is the reason why I can not save the document properly.