I would like to get other info from Okta, because with this.props.auth.getUser()
I’ll receive only email, name and surname about user. But there are many data on Okta for example state, city, street address, zip code and so on.
I’m creating a web app with ReactJS and Node express and the login is managed by Okta (https://developer.okta.com/), then I would like to store the Okta information about users in a database.
async checkAuthentication() {
const authenticated = await this.props.auth.isAuthenticated();
if (authenticated !== this.state.authenticated) {
const user = await this.props.auth.getUser();
console.log(this.props.auth);
this.setState({
authenticated,
user
});
this.getUsers();
}
}
async getUsers() {
let params = "";
let url = "";
if (this.state.user != null) {
params += "EMAIL=" + this.state.user.email;
}
url = params == null ? "/user" : "/user?";
url += params;
this.state.users = await this.fetch('get', url);
if (this.state.users && Object.keys(this.state.users).length == 0) {
this.saveUser();
}
}
async saveUser() {
var user = {
EMAIL: this.state.user.email,
NAME: this.state.user.given_name,
SURNAME: this.state.user.family_name,
//ORGANIZATION: "this.state.user.organization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",
};
await this.fetch('post', '/user', user);
}
Here I would like to save the other data from Okta.
//ORGANIZATION: "this.state.user.organization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",