admin管理员组文章数量:1025296
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 (/), 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.useranization",
//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.useranization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",
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./), 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.useranization",
//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.useranization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",
Share
Improve this question
edited Jan 14, 2019 at 16:48
Sebastian Simon
19.6k8 gold badges61 silver badges84 bronze badges
asked Jan 14, 2019 at 16:02
FabioFabio
492 silver badges7 bronze badges
0
2 Answers
Reset to default 2auth.getUser() returns the details available under /userinfo endpoint on the authorization server through which the user got authenticated and authorized, as described here.
If you would like to publish other details also on this /endpoint, please do the following:
- navigate from your Okta tenant to Admin >> API >> Authorization Server >> your authorization server
- under Claims tab, add new claims with the user's profile values and, under "Include in token type", select "ID Token" and "Userinfo / id_token request"
You need to specify what you want as scope. Okta has default scopes which are the following offline_access, phone, address, email, profile, openid.In the configuration, you can use these docs https://developer.okta./authentication-guide/implementing-authentication/
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 (/), 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.useranization",
//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.useranization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",
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./), 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.useranization",
//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.useranization",
//PHONE = "this.state.user.primaryPhone",
//STATE = "this.state.user.state",
//STREET_ADDRESS = "this.state.user.streetAddress",
//ZIP_CODE = "this.state.user.zipCode",
Share
Improve this question
edited Jan 14, 2019 at 16:48
Sebastian Simon
19.6k8 gold badges61 silver badges84 bronze badges
asked Jan 14, 2019 at 16:02
FabioFabio
492 silver badges7 bronze badges
0
2 Answers
Reset to default 2auth.getUser() returns the details available under /userinfo endpoint on the authorization server through which the user got authenticated and authorized, as described here.
If you would like to publish other details also on this /endpoint, please do the following:
- navigate from your Okta tenant to Admin >> API >> Authorization Server >> your authorization server
- under Claims tab, add new claims with the user's profile values and, under "Include in token type", select "ID Token" and "Userinfo / id_token request"
You need to specify what you want as scope. Okta has default scopes which are the following offline_access, phone, address, email, profile, openid.In the configuration, you can use these docs https://developer.okta./authentication-guide/implementing-authentication/
本文标签:
版权声明:本文标题:javascript - How to get user info from Okta, other than name, surname and email? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745619031a2159463.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论