【问题标题】:OAuth2_GrantType_UserCredentials with Restler带有 Restler 的 OAuth2_GrantType_UserCredentials
【发布时间】:2014-01-09 21:01:47
【问题描述】:

有人有 OAuth2_GrantType_UserCredentials 和 Restler 的样本吗? 我自己试过,但很难理解

谢谢

【问题讨论】:

    标签: restler


    【解决方案1】:

    在您的存储类中,在我的例子中是 PDO,您需要查看以下函数。确保您在第一个中进行了验证。

    public function checkUserCredentials($email, $password) {}
    public function getUserDetails($username) {}
    

    然后

    POST https://{your_server}/token
    

    使用以下有效负载(显然已更改为适合您的环境):

    email=me@myemail.com&
    password=mypassword&
    grant_type=password
    client_id=myclient_id
    

    这里重要的是 grant_type,它实际上是您尝试的“密码”。

    【讨论】:

      【解决方案2】:

      不知道你在问什么。如果您的服务器上已经设置了 OAuth 2,您只需将 grant_type 更改为 'client_credentials' 并传递 client_id 和 client_secret 以换取令牌。例如,在我的 index.php 页面上,我可以通过以下方式获取令牌:

      index.php/grant?grant_type=client_credentials&client_id=demoapp&client_secret=demopass

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 2015-08-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-16
        相关资源
        最近更新 更多