# Using okta hosted login widget

**URL:** <https://devforum.okta.com/t/using-okta-hosted-login-widget/16656>\
**Category:** Questions\
**Created:** [October 19, 2021, 11:07pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656 "2021-10-19T23:07:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richie](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/richie/32/3362_2.png) [@Richie](https://devforum.okta.com/u/Richie)\
**Post date:** [October 19, 2021, 11:07pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/1 "2021-10-19T23:07:56Z")

</div>

I have managed to get the authenticated user over to my application. But my application needs to know what the new user’s email address is. How can I get this? I am programming on php under docker.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [October 21, 2021, 4:28pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/2 "2021-10-21T16:28:09Z")

</div>

What type of application are you working on? Is it an OIDC app? If so, you can get the user’s email from an ID token [if/when you request the ‘email’ scope](https://developer.okta.com/docs/reference/api/oidc/#scope-dependent-claims-not-always-returned).

---

<div class="post-metadata">

**Author:** ![Richie](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/richie/32/3362_2.png) [@Richie](https://devforum.okta.com/u/Richie)\
**Post date:** [October 21, 2021, 4:45pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/3 "2021-10-21T16:45:32Z")

</div>

Hi Andrea. Here is my application description. It is a freemium application running on the open internet that allows users to develop a study for their own use. I store each user’s info under their email address. I store the users email address on my system in AWS RDS. Once a user authenticates and gets passed into my app, I need to determine their email address so I can download their artifacts and their data in general.

Is their a way that I can determine the email of a newly passed in user? I am using the okta hosted login widget.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [October 21, 2021, 8:37pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/4 "2021-10-21T20:37:15Z")

</div>

Its very doable if you configure the app as an [OpenID Connect](https://developer.okta.com/docs/concepts/oauth-openid/) application. Like I was hinting at earlier, if your applications requests ID tokens on behalf of the user, you can request the ‘email’ scope when you do so, which means that the payload for the id token will include a claim containing the users email address.

Another option is to make a AJAX/Fetch request to the [/users/me endpoint](https://developer.okta.com/docs/reference/api/users/#get-current-user). As long as the user has an active session in the browser AND their browser does not block third party cookies (the okta session cookie used for this call is on the okta domain), you can get information about the user back, including their profile in Okta.

If you are worried about browsers that block third party cookies or need to access this information from a backend, I definitely recommend looking into OIDC. Maybe check out one of our samples to get started: [Okta, Inc · GitHub](https://github.com/okta/?q=samples-&type=&language=&sort=)

---

<div class="post-metadata">

**Author:** ![Richie](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/richie/32/3362_2.png) [@Richie](https://devforum.okta.com/u/Richie)\
**Post date:** [October 22, 2021, 12:13am UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/5 "2021-10-22T00:13:31Z")

</div>

Thanks Andrea. Can I stick with the okta hosted login and also use openid?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [October 22, 2021, 12:54am UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/6 "2021-10-22T00:54:53Z")

</div>

Absolutely! If you construct an /authorize request and then paste it in your browser, it will redirect you to Okta to login (if you’re not already logged in), before sending you back to your application (via a redirect\_uri in the request) with the tokens, so you don’t even have to use an embedded login page.

This is how our okta-hosted-login samples work, if you want to see it in action. I’m biased towards React: [samples-js-react/okta-hosted-login at master · okta/samples-js-react · GitHub](https://github.com/okta/samples-js-react/tree/master/okta-hosted-login)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 8, 2024, 7:47pm UTC](https://devforum.okta.com/t/using-okta-hosted-login-widget/16656/7 "2024-02-08T19:47:07Z")

</div>


