When I try to integrate Stripe payments (either Live or Test) with my Telegram bot through Botfather, it fails when I complete the OAuth flow.
This happens only with an Indian Stripe account
Steps to reproduce
I go to @Botfather where I select the bot I want to integrate payments with, and then I select "Stripe" from the Payments option.
It forwards me to @Stripe or @StripeTestBot depending on whether I want to do test integration or live integration.
Stripe bot gives me an OAuth URL which looks something like this:
I then go to this URL to authorize the integration and select the
required account (based in India). (Screenshot attached -
AuthScreen.png)
I then receive this message from Stripe
Bot: "Couldn't connect Stripe account, OAuth has failed. Please try
again later." (Screenshot attached -- BotResponse.png)
If I try to authorize another account based in Germany, then this process is successful.
The problem occurs only with the Indian account.
Device info
Tried Telegram Desktop, Telegram App for Android, Telegram Web K
I contacted Stripe support and here is the info they provided after debugging the messages in the Events log.
# QUOTE BEGINS > It looks like the authorization_code is being used more than once which leads to disconnecting again. The exact error we are seeing is 'OAuth Token was consumed twice, which disconnected this account from the platform'. During the Oauth onboarding process, there are two operations initiated by the platform : the authorize and the Oauth token request.
The authorize is a link that redirects the new user to their onboarding form :
The access token can be used to make requests on behalf of this connected account, but for security reasons, the <authorization_code> can only be used once. If ever re-used, this would lead to disconnecting the connected account from the platform.
Log in here to report bugs or suggest features. Please enter your phone number in the international format and we will send a confirmation message to your account via Telegram.
# QUOTE BEGINS
> It looks like the authorization_code is being used more than once which
leads to disconnecting again. The exact error we are seeing is 'OAuth
Token was consumed twice, which disconnected this account from the
platform'. During the Oauth onboarding process, there are two operations
initiated by the platform : the authorize and the Oauth token request.
The authorize is a link that redirects the new user to their onboarding form :
https://stripe.com/docs/connect/oauth-reference#get-authorize
When this form is completed, Stripe responds with an <authorization_code>, or ac_ :
https://stripe.com/docs/connect/oauth-reference#get-authorize-response
This ac_ will be passed in the token request [1], in order to generate an access token [2] :
[1] https://stripe.com/docs/connect/oauth-reference#post-token
[2] https://stripe.com/docs/connect/oauth-reference#post-token-response
The access token can be used to make requests on behalf of this
connected account, but for security reasons, the
<authorization_code> can only be used once. If ever re-used, this
would lead to disconnecting the connected account from the platform.
# QUOTE ENDS