将身份验证代码交换为令牌的最佳方法 [英] Best approach for exchanging auth code to tokens

查看:34
本文介绍了将身份验证代码交换为令牌的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道将用户作为快速帐户关联到我的 Stripe 平台的最佳方法.我对以下两种方法感到困惑:

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:

方法一

  1. 我在网站前端显示了一个连接到条带"按钮,该按钮具有指向同一页面的 redirect_uri 参数.

  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.

用户点击它,进入条纹界面,填写必要的详细信息,然后使用授权代码返回到我网站的同一页面.

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.

然后我向我的服务器发送一个 ajax 请求,提供我通过从服务器发出 POSt 请求来交换令牌的授权代码.

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

方法二

  1. 我在站点的前端显示了一个连接到条带"按钮,该按钮具有指向我的 API 的某些 GET 路由的 redirect_uri 参数(不是方法 1 中的前端).

  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).

用户点击它,进入条带界面,填写必要的详细信息,然后被重定向到该 API GET 路由,在那里我处理授权代码并发送 POST 请求以交换令牌代码,一旦我拥有它, 我将用户重定向回网站的前端.

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.

所以基本上用户在 API 的 GET 页面上看不到任何东西,但加载和重定向.

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

出于某种原因,方法 2 似乎更合适或者有更好的方法.

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

感谢任何帮助.

推荐答案

我也会选择 #2.也许您可以像这样在顶部添加一些简单且轻量级的 HTML,以便用户知道发生了什么事情.

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>

这篇关于将身份验证代码交换为令牌的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆