# Client Account linking with Passwordless SMS and Email, error "Invalid token (link\_with)."

**URL:** <https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501>\
**Category:** Get Help\
**Tags:** linking-account\
**Created:** [September 10, 2020, 1:38am UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501 "2020-09-10T01:38:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.jerochim](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.jerochim/32/16371_2.png) [@chris.jerochim](https://community.auth0.com/u/chris.jerochim)\
**Post date:** [September 10, 2020, 1:38am UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501/1 "2020-09-10T01:38:00Z")

</div>

Hi there,

I’m working through an embedded implementation of a Passwordless authentication with Flutter.

The overall goal is to authenticate first with SMS and later within the user flow, we want to have a secondary authentication with email.

Both are Passwordless on the same Auth0 Application client.

Here is the current solution:

**SMS**

1. User authenticates via SMS passwordless hitting the `https://[domain]/passwordless/start` end point

2. Once the code comes through, I verify the token with the following call to the endpoint  
`https://[domain]/oauth/token`

This call includes defining the following:

- `audience: https://[doman]/api/v2/`
- `scope: openid profile update:current_user_identities`

This returns a JWT access token

**Email**

1. User authenticates via Email passwordless hitting `https://[domain]/passwordless/start` end point with the email configuration requesting code

2. Submit the email code with the following endpoint:  
‘https://[domain]/oauth/token’

This also includes the additional attributes:

- `audience: https://[doman]/api/v2/`
- `scope: 'openid profile update:current_user_identities`

Also returns a JWT access token

**Link accounts**

The goal is to link both SMS account as the primary and Email to be secondary account.

Call the following endpoint:  
`https://[domain]/api/v2/users/[primary Account user id]/identities`

Header Bearer [primary account access token]

The body contains:  
`link_with`: `[secondary account access token]`

I get the following error as a response  
` {"statusCode":400,"error":"Bad Request","message":"Invalid token (link_with).","errorCode":"invalid_body"}`

I’m probably missing something really obvious, just wanted to get further clarity?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![sgo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sgo/32/13789_2.png) [@sgo](https://community.auth0.com/u/sgo)\
**Post date:** [September 11, 2020, 4:50pm UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501/2 "2020-09-11T16:50:21Z")

</div>

Heya @chris.jerochim!

This looks ok from what you are saying, how are you making these calls? Have you tried issuing the call with just cURL commands, manually providing the relevant tokens?

If you are still having issues doing it manually, could you please share the cURL command including tokens that you are using in the last step to me in a direct message?  
There may be something wrong with the secondary token based on that error message.

---

<div class="post-metadata">

**Author:** ![chris.jerochim1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.jerochim1/32/28635_2.png) [@chris.jerochim1](https://community.auth0.com/u/chris.jerochim1)\
**Post date:** [April 7, 2021, 12:35pm UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501/3 "2021-04-07T12:35:31Z")

</div>

After investigating further I’ve managed to resolve the issue.

Ensure you pass in the `id_token` to the `link_wth` attribute, not the access token.

This fixed the problem!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 7, 2021, 2:56pm UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501/4 "2021-04-07T14:56:50Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 22, 2021, 2:57pm UTC](https://community.auth0.com/t/client-account-linking-with-passwordless-sms-and-email-error-invalid-token-link-with/49501/5 "2021-04-22T14:57:21Z")

</div>

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