# Ask existing account to authenticate with another identity provider (and other NemID questions)

**URL:** <https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040>\
**Category:** Get Help\
**Tags:** identity, provider\
**Created:** [November 11, 2020, 10:27am UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040 "2020-11-11T10:27:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wizhi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wizhi/32/15135_2.png) [@wizhi](https://community.auth0.com/u/wizhi)\
**Post date:** [November 11, 2020, 10:27am UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040/1 "2020-11-11T10:27:16Z")

</div>

I’m creating an application in which users may _optionally_ verify their identity using the Danish NemID system.

I’ve seen that Auth0 supports [authentication with NemID through Criipto](https://auth0.com/docs/connections/criipto/nemid), which seems reasonable, but I’m unsure if Auth0 supports asking an existing user, who has already authenticated using one identity provider, to authenticate with a second identity provider.

I’ve found the documentation on [User Account Linking](https://auth0.com/docs/users/user-account-linking), but from what I can see, this only supports linking two _existing_ accounts together. I want users to be able to authenticate with other social identity providers, and then further authenticate with NemID, which doesn’t seem to match what account linking is used for.

**How can I prompt an existing account, which has authenticated using e.g. Facebook, to also authenticate with NemID (and hopefully link these two “accounts”)?**

This is possibly in the documentation somewhere, but I haven’t been able to find it.

I have two further questions, but I’m unsure if this is related to Auth0 or the NemID provider, being Criipto. I’ll take my chances and ask here first.

**Criipto provides various legal information about the user, which is linked to their SSN and thus legally verifyable, will Auth0 provide this information as part of the identity metadata?**

**Are NemID identities unique? E.g. if account A further authenticates with NemID, and account B attempts to authuenticate with NemID using the same credentials, will the authentication attempt be rejected?**

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![joseantonio.rey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joseantonio.rey/32/14670_2.png) [@joseantonio.rey](https://community.auth0.com/u/joseantonio.rey)\
**Post date:** [November 19, 2020, 2:41am UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040/2 "2020-11-19T02:41:02Z")

</div>

Hey @wizhi - welcome to the Auth0 Community!

In order to link two accounts, both of them need to exist within Auth0. In order for it to exist, as you have now figured out, a federation must happen.

In order to force a login while a session already exists in Auth0, you can use the `prompt=login` parameter in your `/authorize` request. This will prompt the user for logging in once again, even when a session already exists.

Let me know if this helps to support your query.

---

<div class="post-metadata">

**Author:** ![wizhi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wizhi/32/15135_2.png) [@wizhi](https://community.auth0.com/u/wizhi)\
**Post date:** [November 23, 2020, 12:52pm UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040/4 "2020-11-23T12:52:35Z")

</div>

Hi @joseantonio.rey,

Thanks for the reply.

I think you might have misunderstood my intention - or maybe I’m misunderstanding the documentation. 🙂

In [the documentation for the `prompt` parameter of the `/authorize` endpoint](https://auth0.com/docs/api/authentication#authorization-code-flow), it says to see the associated remarks, which state:

> Silent authentication lets you perform an authentication flow where Auth0 will only reply with redirects, and never with a login page. When an Access Token has expired, silent authentication can be used to retrieve a new one without user interaction, assuming the user’s Single Sign-on session has not expired.

I think the inteded usage for this would be refreshing the token of an active session.  
Setting `prompt=login` would, from your explanation, _prompt_ the user to login using the interface of the specified `connection`, correct?

That’s not what I’m actually looking for.

I’m looking for a way, in which I can have _an existing account_ perform an authentication request to another identity provider, resulting in _the existing account_ being automatically linked to the “newly created” account.

Since creating this thread, I did stumble upon [this legacy endpoint](https://auth0.com/docs/api/authentication#link), which does _exactly_ what I want.  
The problem is, however, that it’s been _deprecated_ [for security reasons](https://auth0.com/docs/product-lifecycle/deprecations-and-migrations/past-migrations#account-linking-removal), which is fair.

I’ve personally come to the conclusion that Auth0 simply doesn’t support this anymore, and I need to work around it.

My current idea would be something like…

1. User initially authenticates using `IdP A`, resulting in the creation of `Account A`
2. Save access token of `Account A` in a semi-persistent storage of my application, such as a cookie
3. Initiate a new authentication flow for `IdP B`, resulting in the creation of `Account B`
4. The authentication flow will eventually redirect back to my application, with the access token for `Account B`
5. Detect that an access token already exists in my application’s storage
6. Link the account of the _existing_ access token with the account of the _new_ access token using the Management API (meaning I need to setup a proxy request), meaning `Account A` is the _primary_ account, with `Account B` being the _secondary_ account
7. Discard the _new_ access token, since this should be for the _secondary_ account which, according to Auth0 logic, no longer actually exists
8. Have the user continue to use the _old_ access token, which now belongs to the _linked_ account

Honestly this is messy, and requires the client to be far more involved, which I find particularly annoying.

I haven’t implemented the actual client in this case either, but have been given the task of adding the NemID authentication integration to existing accounts, so I’m unsure if the `auth0.js` SDK even supports this flow, or if we need to add more custom things for it.

If you can think of any way to make this more streamlined, I’d highly appreciate it.  
Again, the [sadly deprecated endpoint](https://auth0.com/docs/api/authentication#link) in question does _exactly_ what I want, and I wish there was something to replace it.

Thank in advance.

---

<div class="post-metadata">

**Author:** ![joseantonio.rey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joseantonio.rey/32/14670_2.png) [@joseantonio.rey](https://community.auth0.com/u/joseantonio.rey)\
**Post date:** [November 23, 2020, 6:41pm UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040/5 "2020-11-23T18:41:10Z")

</div>

Hello, @wizhi,

Aha, that makes sense. Indeed, the flow that you are describing is exactly what you would need to do in this case.

What I was mentioning with the `prompt=login` is that you can leverage that to force step 3, instead of having the user log out and log back in.

What you have described, though, is on point.

---

<div class="post-metadata">

**Author:** ![jack1111](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jack1111/32/57497_2.png) [@jack1111](https://community.auth0.com/u/jack1111)\
**Post date:** [June 6, 2024, 1:39pm UTC](https://community.auth0.com/t/ask-existing-account-to-authenticate-with-another-identity-provider-and-other-nemid-questions/53040/6 "2024-06-06T13:39:52Z")

</div>

thank you so much your most important information share. [samagra portal](https://sssmidportal.com/)
