This is not supported out of the box.
What you can do is the following (requires tweaking of the order, mainly switching the order):
- Sign in with custom auth using slack: (the uid used here in the custom auth account could be the same as the slack user identifier).
- linkWithPopup/Redirect/Credential using the Google provider or credential to the existing slack custom user.
If you insist on the proposed flow, you can do the following:
- Sign in with Google first (uid allocated).
- Sign in with Slack (slack OAuth credential obtained).
- Send Firebase ID token and slack credential to your backend.
- Verify Firebase ID token, query slack userinfo endpoint to get slack user data, including slack identifier.
- Save a hash map with the Slack identifier as key and the Firebase uid as value, another hash map with firebase uid as key and slack identifier as value.
- Mint a custom token with the firebase uid, set slack custom attribute (slack: {Slack Identifier}).
- Send custom token to front end and signInWithCustomToken (slack identifier will now be available in token)
- The slack account is now linked to the existing account.
The next time the user logs in with Slack:
- Send the slack OAuth credential to the backend.
- Query slack userinfo to get slack identifier.
- Check hash map using slack identifier key for corresponding firebase uid.
- Mint custom token with firebase uid, add slack identifier as custom attribute.
- sign in with custom token on the client.
If the user signs in with Google.
- Send firebase ID token to the backend.
- Verify ID token, lookup corresponding slack identifier in the hash map with firebase uid keys.
- Mint custom token with Firebase uid and slack identifier as custom attribute.
- sign in with custom token on the client.