# Using Auth0 login in iFrame

**URL:** <https://community.auth0.com/t/using-auth0-login-in-iframe/91547>\
**Category:** Get Help\
**Tags:** iframe, new-universal-login, invalid, state, classic-universal-login, anomaly-detection, login\
**Created:** [September 29, 2022, 2:37pm UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547 "2022-09-29T14:37:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeel/32/34106_2.png) [@adeel](https://community.auth0.com/u/adeel)\
**Post date:** [September 29, 2022, 2:37pm UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/1 "2022-09-29T14:37:17Z")

</div>

- SDK Version: 1.9.1
- Platform Version: Next Js

**Use Case:** We need to open our Auth0 Next Js app in a third party app using an iframe. It throws error when using New Universal Login. Secondly, by using Classical login, login call returns error.  
Note: Our app works fine when used without iframe

1. Can we use New Universal Login with an iframe ?

2. According to the docs,

- We are using Classical Universal Login
- Disabled Clickjacking for Classical Universal Login from Settings

We can successfully login on a standalone auth0 nextjs app. However, if we use the same app in an iframe we see two network calls:

1. Login call with url {DOMAIN}/usernamepassword/login ==\> Error 403  
**Payload:**

```auto
{
    "client_id": {{CLIENT_ID}},
    "redirect_uri": "http://localhost:3002/api/auth/callback",
    "tenant": "dwdev",
    "response_type": "code",
    "scope": "openid profile email",
    "state": "hKFo2SBBX3lBcmpaX043a0FEcGJKelR1X0RoR290OHZVcVhIOKFupWxvZ2luo3RpZNkgZjRhTEFZbUQ3anpoS25ON1l2cW9rbUhtQ3ZuaGFWRlCjY2lk2SBtRmFUYmFYd2ZqMFAwcnhOOGV0MXlMT1NWTktvenUyZg",
    "nonce": "QIJjsKdjm4rjnZHeqhmG3b6R3dFpMiYahAhi32zCByg",
    "connection": "dw-db",
    "username": "janedoe",
    "password": "password",
    "popup_options": {},
    "sso": true,
    "_intstate": "deprecated",
    "_csrf": "5C2roH8F-imlQoAVsX62ALJlmKK_2GUExtfU",
    "audience": {{AUDIENCE}},
    "code_challenge_method": "S256",
    "code_challenge": "6xjFmJtswZR9wCH7v6FHbGsZlEIOc-s8Wao2aURoqZ8",
    "protocol": "oauth2",
    "type": "code"
}

```

**Response:**

```auto
{
    "statusCode": 403,
    "description": "Invalid state",
    "name": "AnomalyDetected",
    "code": "access_denied"
}

```

1. Challenge call with url {DOMAIN}/usernamepassword/challenge ==\> Error 404

---

<div class="post-metadata">

**Author:** ![hakeem](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hakeem/32/33835_2.png) [@hakeem](https://community.auth0.com/u/hakeem)\
**Post date:** [September 29, 2022, 5:05pm UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/4 "2022-09-29T17:05:54Z")

</div>

Facing the same problem.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 29, 2022, 8:45pm UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/5 "2022-09-29T20:45:41Z")

</div>

Hey there @adeel welcome to the community!

> [@adeel](#):
>
> - Can we use New Universal Login with an iframe ?

New Universal Login does not support the use of iframes.

Assuming the the iframe and app itself are on different domains, you might want to look into cookies that are being blocked by the iframe. It’s good to know that your login flow is working outside of the context of an iframe - This definitely narrows it down a bit.

---

<div class="post-metadata">

**Author:** ![adeel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeel/32/34106_2.png) [@adeel](https://community.auth0.com/u/adeel)\
**Post date:** [September 30, 2022, 8:07am UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/7 "2022-09-30T08:07:41Z")

</div>

Thanks for your response.

I have switched to classic Universal Login from New Universal Login and also disable the clickjacking for classic Universal Login, but still unable to login with that .

How can I know that which cookies is blocking on iframe?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 22, 2022, 12:25am UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/8 "2022-12-22T00:25:40Z")

</div>



---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 14, 2024, 10:23pm UTC](https://community.auth0.com/t/using-auth0-login-in-iframe/91547/9 "2024-05-14T22:23:50Z")

</div>

Doing a bit of combing through our backlog and wanted to update this topic for any future users ending up here 🔮

There is some configuration required in order to allow for logging in using an iframe:

> <https://github.com/auth0/nextjs-auth0/pull/571>
>
> \### Description
> 
> Honor the \`SameSite\` configuration (which defaults to 'lax') …when setting the transient nonce/state cookies.
> 
> This will allow users to login to iframes over https when using the \[AUTH0\_COOKIE\_SAME\_SITE\](https://auth0.github.io/nextjs-auth0/interfaces/config.cookieconfig.html#samesite) config set to \`'none'\`
> 
> \### References
> 
> Same as https://github.com/auth0/express-openid-connect/pull/188
> fixes #541 
> 
> \### Testing
> 
> Tested by logging in to auth0 from an iframe in https://codepen.io/adamjmcgrath/pen/bGoKBMW
> 
> \### Checklist
> 
> \- \[x\] I have added documentation for new/changed functionality in this PR or in auth0.com/docs
> \- \[x\] All active GitHub checks for tests, formatting, and security are passing
> \- \[x\] The correct base branch is being used, if not \`main\`

In particular you will need to set [AUTH0\_COOKIE\_SAME\_SITE](https://auth0.github.io/nextjs-auth0/types/config.ConfigParameters.html#md:optional) to `none`.
