首页 > 解决方案 > 是否可以添加自定义接受页面以登录亚马逊

问题描述

我有一个 Google SmartHome 应用程序,其中 Google 需要 Google SmartHome 设备的“特殊”接受/免责声明页面。我们目前正在使用自定义 OAuth 2.0 服务器并拥有自己的登录页面。对于当前设置,附加登录页面不是问题。这类似于询问用户是否同意允许应用程序访问配置文件信息的标准登录亚马逊 (LWA) 页面。是否可以自定义该页面或向流程添加其他页面。对于一个额外的中间页面,我在想这样的事情:

下面的代码块当然不起作用。它意味着更多的伪代码。我不知何故需要使用 OAuth 参数执行新的 GET,然后以某种方式“让开”/重定向回最初的 SmartHome 请求。

[httpGet] 
public ActionResult Index(string client_id, string redirect_uri, string state, string scope, string response_type)
        {
            ViewBag.Client_id = client_id;
            ViewBag.Redirect_uri = redirect_uri;
            ViewBag.State = state;
            ViewBag.Scope = scope;
            ViewBag.Response_type = response_type;

            return View();
        }
[httpPost] 
public ActionResult Accept(string client_id, string redirect_uri, string state, string scope, string response_type)
        {
           //don't know how return the query string
           return RedirectPermanentPreserveMethod("https://www.amazon.com/ap/oa");
        }
...


标签: asp.net-core-mvcgoogle-oauthamazon

解决方案


所以如果你只看一下redirectPermenent的文档就不是那么难了

public ActionResult Index(string client_id, string redirect_uri, string state, string scope, string response_type)
        {
            ViewBag.Client_id = client_id;
            ViewBag.Redirect_uri = redirect_uri;
            ViewBag.State = state;
            ViewBag.Scope = scope;
            ViewBag.Response_type = response_type;

            return View();  //disclaimer 
        }
[httpPost] 
public ActionResult Accept(string client_id, string redirect_uri, string state, string scope, string response_type)
        {
          string uri = "https://www.amazon.com/ap/oa?" + "client_id=" + Client_id + "&redirect_uri=" + Redirect_uri + "&state=" + State + "&scope=" + Scope + "&response_type=" + Response_type;
           return RedirectPermanentPreserveMethod(uri);
        }
'''

推荐阅读