Okta登录小部件获取名称和头像

问题描述 投票:0回答:1

[在这种情况下,我可以使用Okta登录小部件登录,它返回用户的电子邮件和用户ID(okta)。

我使用了它,但是现在我的客户要求我至少要设置名称,因此需要完成。

事实是,我看到了/ me端点如何向我返回所需的数据,但是我无法从AngularJS范围或Okta登录小部件SDK中进行访问

但是我无法访问它。使用sessiong.get()函数,它仅检索userId和电子邮件。

var oktaSignIn = new OktaSignIn({
                  baseUrl: 'https://dev-893652.oktapreview.com',
                  clientId: '0oaj1v2jfyKeTwLR60h7',
                  redirectUri: 'https://movielearningv4.app.keetup.com',
                  authParams: {
                    issuer: 'https://dev-893652.oktapreview.com/oauth2/default',
                    scopes: ['openid', 'email', 'profile'],
                    responseType: ['id_token','token'],
                    display: 'page'
                  }
          });

if (oktaSignIn.token.hasTokensInUrl()) {
                oktaSignIn.token.parseTokensFromUrl(function success(res) {
                    // The tokens are returned in the order requested by `responseType` above
                    var accessToken = res[0];
                    var idToken = res[1]
                    console.log("response", res)
                    // Say hello to the person who just signed in:
                    console.log('Hello, ' + res);
                    // Save the tokens for later use, e.g. if the page gets refreshed:
                    oktaSignIn.tokenManager.add('accessToken', accessToken);
                    oktaSignIn.tokenManager.add('idToken', idToken);
                    oktaSignIn.session.get(function (response) {
                  // Session exists, show logged in state.
                  // Doesn't return name
                          console.log("response", response)

                    // Remove the tokens from the window location hash
                    window.location.hash='';
                                     if (res.status === 'ACTIVE') {
                                        console.log('Welcome , ' + res.login);
                                        return;
                                      }

                     });
                  }, function error(err) {
                    // handle errors as needed
                    console.error(err);
                  });
              } else {

                oktaSignIn.session.get(function (res) {
                  console.log("RESPONSES!", res)
                  if (res.status === 'ACTIVE') {
                    console.log('Response active!, ' + res);
                   // Also doesn't return name
                    return;
                  }
                  // No session, show the login form
                  oktaSignIn.renderEl({ el: '#okta-login-container' },
                    function success(res) {
                      // Nothing to do in this case, the widget will automatically redirect
                      // the user to Okta for authentication, then back to this page if successful
                      console.log("success", res)

                    },
                    function error(err) {
                      // handle errors as needed

                      console.error("error session", err);
                    }
                  );
                });
              } 

如何使用Widget Okta SDK获得用户的名称和头像?

javascript node.js login okta
1个回答
0
投票

我也面临类似的问题,并且在以下方法中代码被破坏:如果(SignIn.hasTokensInUrl()){SignIn.authClient.token.parseFromUrl(

发布此URL不会被解析,并最终以:token.js:666Uncaught TypeError: e.indexOf is not a function at _ (token.js:666) at Object.parseFromUrl (util.js:70) at Login_Policy.html:99谁能建议相同的解决方案?我正在使用CDN 3.5作为脚本源。

© www.soinside.com 2019 - 2024. All rights reserved.