Best approach for exchanging auth code to tokens

天大地大妈咪最大 提交于 2019-12-13 06:27:02

问题


I would like to know the best approach to associate a user as express account to my stripe platform. I have confusion between following two approaches:

Approach 1

  1. I show a "connect to stripe" button on the front end of the site which has a redirect_uri parameter to the same page.

  2. User clicks on it, goes to stripe interface, fills up necessary details and gets back to the same page of my site with authorize code.

  3. Then I send an ajax request to my Server providing that authorize code which I exchange for tokens by making POSt request from Server.

Approach 2

  1. I show a "connect to stripe" button on the front end of the site which has a redirect_uri parameter to the some GET route of my API (not front end as in approach 1).

  2. User clicks on it, goes to stripe interface, fills up necessary details and then gets redirected to that API GET route, where I process the authorize code and send POST request to exchange code for tokens and once I have it, I redirect user back to the front end of the site.

So basically user doesnt see anything while being on GET page of the API but loading and redirection.

For some reason Approach 2 seems more suitable or is there any better approach.

Any help is appreciated.


回答1:


I would go with #2 aswell. Maybe you can add some simple and lightweight HTML at the top like this so the user knows something is going on.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Working...</title>
  </head>
  <body>
    <center>
      <h1>Please wait...</h1>
      <h2>Processing your request. You will soon be redirected.</h2>
      </center>
  </body>
</html>


来源:https://stackoverflow.com/questions/54717924/best-approach-for-exchanging-auth-code-to-tokens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!