# Sharing authentication with another domain

**URL:** <https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476>\
**Category:** OAuth/OIDC\
**Tags:** javascript\
**Created:** [November 18, 2022, 12:56am UTC](https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476 "2022-11-18T00:56:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson.langford](https://avatars.discourse-cdn.com/v4/letter/g/f475e1/32.png) [@grayson.langford](https://devforum.okta.com/u/grayson.langford)\
**Post date:** [November 18, 2022, 12:56am UTC](https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476/1 "2022-11-18T00:56:31Z")

</div>

Hello,

I have two apps: [a.mydomain.com](http://a.mydomain.com), and [b.mydomain.com](http://b.mydomain.com). When I login to one app, I would like to also be logged into the other without having to re-authenticate. Is sharing authentication with another domain possible using Okta React or okta-auth-js?

---

<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:** [December 21, 2022, 6:42pm UTC](https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476/2 "2022-12-21T18:42:02Z")

</div>

Why not have the second app trigger its own /authorize request once user access it? At that point, they will already have an Okta session (created when logging into the first app) and will not be prompted to re-auth (provided the user does not need to provide additional verification specific to this application) when the second authorize call occurs.

In AuthJS, you would use `getWithRedirect` to trigger this manual /authorize request or `getWithoutPrompt` if your Okta domain is on the same domain as your applications (e.g. its hosted at [login.mydomain.com](http://login.mydomain.com))

---

<div class="post-metadata">

**Author:** ![grayson.langford](https://avatars.discourse-cdn.com/v4/letter/g/f475e1/32.png) [@grayson.langford](https://devforum.okta.com/u/grayson.langford)\
**Post date:** [December 21, 2022, 7:05pm UTC](https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476/3 "2022-12-21T19:05:13Z")

</div>

Hi Andrea,

Thanks for the reply! A workaround was found in line with your suggestion. If a session already exists, we make a call to oktaAuth.token.getWithoutPrompt, and the tokens it returns without having to login again:

```auto
  useEffect(() => {
    oktaAuth.session.exists().then(exists => {
      if (exists) {
        // logged in
        oktaAuth.token
          .getWithoutPrompt({ responseType: 'id_token' })
          .then(res => {
            const { tokens } = res;

            oktaAuth.tokenManager.setTokens(tokens);
          })
      }
    });
  }, []);

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 12, 2024, 10:40pm UTC](https://devforum.okta.com/t/sharing-authentication-with-another-domain/22476/4 "2024-02-12T22:40:10Z")

</div>

Closed on February 12, 2024, 10:40pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
