|
| 1 | +# MSC4178: Error codes for requestToken |
| 2 | + |
| 3 | +There are a number of ways that sending a token to validate a third party identifier can go wrong. |
| 4 | +The requestToken API, however, has a very limited number of error codes that it can return. |
| 5 | + |
| 6 | +Firstly, homeservers may not always support adding email addresses or phone numbers to a user's account, |
| 7 | +however, there is no error code to signal this situation. Synapse currently returns `M_UNKNOWN` |
| 8 | +which leads to bad, untranslatable error messages. |
| 9 | + |
| 10 | +Secondly, the supplied third party identifier may be invalid. |
| 11 | + |
| 12 | +## Proposal |
| 13 | + |
| 14 | +Firstly, Add the `M_THREEPID_MEDIUM_NOT_SUPPORTED` code to be returned by both |
| 15 | +[`POST /account/3pid/email/requestToken`](https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3account3pidemailrequesttoken) |
| 16 | +and |
| 17 | +[`POST /account/3pid/msisdn/requestToken`](https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3account3pidmsisdnrequesttoken), |
| 18 | +defined to mean that the homeserver does not support adding a third party identifier of that medium. |
| 19 | + |
| 20 | +Secondly, allow these endpoints to also return `M_INVALID_PARAM`, to indicate that the third party address |
| 21 | +was not valid for that medium (eg. not a valid phone number). |
| 22 | + |
| 23 | +For both of these codes, HTTP status code 400 should be used. |
| 24 | + |
| 25 | +## Potential issues |
| 26 | + |
| 27 | +None foreseen. |
| 28 | + |
| 29 | +## Alternatives |
| 30 | + |
| 31 | +A better UX would be for servers to advertise what third party identifiers they support adding so that clients can |
| 32 | +inform users before they try to do so. This should be in addition rather than as alternative though: the clearest |
| 33 | +possible API will come from having both. |
| 34 | + |
| 35 | +## Security considerations |
| 36 | + |
| 37 | +None foreseen. |
| 38 | + |
| 39 | +## Unstable prefix |
| 40 | + |
| 41 | +This is sufficiently simple that proving it on a large scale is unnecessary. The code should not be used in the open |
| 42 | +before the MSC has been accepted. |
| 43 | + |
| 44 | +## Dependencies |
| 45 | + |
| 46 | +None |
0 commit comments