# Account Linking Two existing Users

**URL:** <https://devforum.okta.com/t/account-linking-two-existing-users/12809>\
**Category:** Questions\
**Created:** [February 5, 2021, 10:05am UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809 "2021-02-05T10:05:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfgang](https://avatars.discourse-cdn.com/v4/letter/w/54ee81/32.png) [@Wolfgang](https://devforum.okta.com/u/Wolfgang)\
**Post date:** [February 5, 2021, 10:05am UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809/1 "2021-02-05T10:05:56Z")

</div>

Hi,

I’m using 3 different idps (Facebook, Azure AD and Gmail).  
It should be possible for Users to Login without having an Account before in Okta using Facebook or Gmail. Therefore JIT is aktivated in all three ipds.

When a User logs in via Facebook a User is created in Okta.  
When the same user logs in via Azure AD another user is Created in Okta.

Is there any possibility to do Account-Linking on these two generated Users manually?  
So that when a user logs in with facebook or with azure ad the user can access both apis?

I have tested automatic account linking via email, but in our use case above we can’t do account linking via this attribute, because we don’t have the information, or the accounts already exists.

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [February 5, 2021, 8:23pm UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809/2 "2021-02-05T20:23:45Z")

</div>

Hello,  
Okta does allow [manual account linking](https://developer.okta.com/docs/concepts/identity-providers/#account-linking), via this [API call](https://developer.okta.com/docs/reference/api/idps/#link-a-user-to-a-social-provider-without-a-transaction). Note this requires the externalId of the account.

> So that when a user logs in with facebook or with azure ad the user can access both apis?

I am not sure I understand what is meant here? Do you mean if a single Okta account linked to both a facebook and Azure account logs in via facebook, that would also automatically authenticate them against Azure? If so that would not happen.

---

<div class="post-metadata">

**Author:** ![Wolfgang](https://avatars.discourse-cdn.com/v4/letter/w/54ee81/32.png) [@Wolfgang](https://devforum.okta.com/u/Wolfgang)\
**Post date:** [February 8, 2021, 6:01am UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809/3 "2021-02-08T06:01:36Z")

</div>

Hi,  
I have seen the manual account linking api, but not sure if its possible to link two already existing users.  
For Example:  
Users:  
“[testuser1@gmail.com](mailto:testuser1@gmail.com)”  
“[testuser1@myaaddomain.com](mailto:testuser1@myaaddomain.com)”  
“[testuser3@oktauser.com](mailto:testuser3@oktauser.com)”

Users with @gmail are Users from idp google. Users with myaaddomain are users from azure ad. User with oktauser are users created direktly in okta.

I wan’t to link [testuser1@gmail.com](mailto:testuser1@gmail.com) which already is listed in users in okta because idp provider google created them, with the user [testuser1@myaaddomain.com](mailto:testuser1@myaaddomain.com) which also already exists in okta.

After this linking testuser1 should be able to get a token for aad and google no matter which login the user choose.

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [February 9, 2021, 5:58am UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809/4 "2021-02-09T05:58:51Z")

</div>

In this case you will want to get the external user id of the user you want to link to the other user with GET [/api/v1/idps/{idpId}/users/{userId}](https://developer.okta.com/docs/reference/api/idps/#get-a-linked-identity-provider-user), then delete that user, and then link them to the other user with POST [/api/v1/idps/{idpId}/users/{userId}](https://developer.okta.com/docs/reference/api/idps/#link-a-user-to-a-social-provider-without-a-transaction)

After this if you login with that user via gmail or azure they should be linked to which ever account you linked to.

---

<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:** [January 26, 2024, 6:50pm UTC](https://devforum.okta.com/t/account-linking-two-existing-users/12809/5 "2024-01-26T18:50:24Z")

</div>


