#sidi_code

1 messages · Page 1 of 1 (latest)

late sirenBOT
#

đź‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

đź”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1220863630132904001

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

jolly knotBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

lethal sedge
#

Before it was working well but now it doesn’t,

tidal night
#

Hi, when is 'before'?

#

Can you share the exact timeline when it stopped working?

#

Did you make any changes on your end recently?

#

Are you still seeing the same error '"StripeInvalidGrantError: This authorization code has already been used. All tokens issued with"'?

lethal sedge
lethal sedge
lethal sedge
#

Now the users stored in stripe connect accounts unlike before, the only issue I've now is with the code.

#

To make it simple for you:
-I do authentication
-I get a unique code, and I send request to get stripe_user_id
-I store stripe_user_id, and code in my DB
-And I being stored in stripe connect accounts
-I try to do authentication again with the same account and I get a different code

#

Is it clear now?

tidal night
#

Can yo uclarify what 'And I being stored in stripe connect accounts' means?

lethal sedge
#

I mean the account get stored in stripe connect accounts like in the image

tidal night
#

Hmm, that sounds like you've already authenticated, and it all sounds like you're trying to re-authenticate that account.

lethal sedge
#

yes

#

But I should get the same code I guess

#

Because my users may be want to connect the same account with another form

#

If I get the code, I can Just check my DB if that account is already there So I don’t run this code:

const response = await stripe.oauth.token({
  grant_type: "authorization_code",
  code,
});
#

And I can just get stripe_user_id directly from the DB

tidal night
#

Can you share the account id that you're trying to connect?

lethal sedge
#

Here it is: acct_1OxEwiDcRF5FAJh9

#

But this is from test mode

tidal night
#

Are you saying it's behaving differently in test mode vs. live?

lethal sedge
#

I mean I'm not sure if this happens in live as well, I still testing locally and on production but with my stripe test keys

tidal night
#

Ok, you mentioned test mode specifically so I was not sure if there was something to it

lethal sedge
#

Is there any solution?

tidal night
#

It looks like this account is already connected so the authorization_code is not going to work. Why are you trying to do the authentication again?

lethal sedge
tidal night
#

I think the issue is that I do not know what you're exactly trying to do.

#

But why?

lethal sedge
#

If I get the code I will avoid using stripe.oauth.token to get stripe_user_id because I already got it, I will just send a request to my DB by the "code" I have and get "stripe_user_id"

#

This will help me avoid '"StripeInvalidGrantError: This authorization code has already been used. All tokens issued with"'

tidal night
#

Yes, but did not you already do that do connect the account?

lethal sedge
#

I'm talking if the user want to connect his stripe with another form. my project is a form builder

#

users can have many forms

tidal night
#

What does 'another form' mean here? Is Form the account? Or something else?

lethal sedge
tidal night
#

But if the account is connected to your account, why are you asking them to connect again?

lethal sedge
lethal sedge
tidal night
#

What does this form do? I do not think I understand the flow here.

lethal sedge
#

This is a form builder, users can create a form to collect data, and some of them may want to receive money and collect data in the same time so they have stripe integration to make this possible

#

If you want I can send a short demo

tidal night
#

So you would have person A who can fill out this form. They may have an existing Stripe account to you're using oAuth to connect them to your Platform. Person A can also fill out a second form and this is where you're seeing this issue?

#

Is that correct?

tidal night
#

On the form, you also have a message that says 'Stripe account is connected' what is that looking at?

#

From your code, it looks like you're querieng the connected accounts? What does that return?

lethal sedge
lethal sedge
# lethal sedge

Because it’s connected, this is how it look if it’s not connected

tidal night
#

So from that code, it does not look you're NOT trying to re-authenticate. You're looking at the connected accounts, and then submitting the form. In this sense, I do not unduerstand why you're trying to re-authenticate. The account is connected, you show that on your UI.

lethal sedge
#

If I get a fixed code for every account I can fix this

tidal night
#

Then, I do not think you want to keep using this. Once you've connected it, you do not need to keep trying to make this request.

lethal sedge
#

But they may try it with another form that isn’t connected?

tidal night
#

What does 'But they may try it with another form that isn’t connected?' mean? Earlier you said that the Person A, who have already filled out the form and connected to your account could come back and fill our the form again.

lethal sedge
#

Normally event if the account is authenticated, and I try to authenticate with the same account again I should get the same code.

tidal night
#

I agree. If it's the same account, it would be the same code. However, you seem to be looking for refresh_token on your code.

When using a refresh token to request an access token, you may use either a test or live API key to obtain a test or live access token respectively. Any existing access token with the same scope and mode—live or test—is revoked.

lethal sedge
#

https://connect.stripe.com/oauth/v2/authorize?response_type=code&client_id=${process.env.STRIPE_CLIENT_ID}&scope=read_write&state=${state}&stripe_user[email]=${session.user.email}

tidal night
#

But the overall flow you're following does not seem right. If the account is already connected, and if you're trying to create a payment on the connected account, you would use the Stripe Account Header.

lethal sedge
#

To get the refresh token?

#

Because that url response only with "code" not "refresh_token"

tidal night
#

Yeah, that part I think is fine. In the response, you're looking at the refresh_token no?

#

We're closing the channel for the weekend.

lethal sedge
tidal night
#

You can write in to our support team to get 1:1 help.

lethal sedge
tidal night
lethal sedge
#

Have a nice weekend