【问题标题】:Multiple authentication in podio php apipodio php api中的多重身份验证
【发布时间】:2014-07-01 10:28:14
【问题描述】:

我使用 podio php api 创建了一个应用程序。登录的用户将使用他的刷新令牌进行身份验证。

Podio::authenticate('refresh_token', array('refresh_token' => USER_REFRESH_TOKEN ));

在某些情况下,我需要将用户详细信息添加到 podio 中的另一个应用程序中。登录的用户无权访问该应用程序。这将导致 Podio Forbidden 错误。

只有应用的管理员才拥有此应用的正确权限。

我们如何验证用户在应用中插入他的详细信息?

【问题讨论】:

    标签: php podio


    【解决方案1】:

    oauth 令牌存储在 Podio::$oauth 中,因此您可以在想要作为不同实体进行身份验证时切换它。

    例如,如果您想在两个不同的应用程序之间切换:

    // Authenticate as the first app
    Podio::authenticate('app', ...);
    
    // Here you can make API requests as the first app
    
    // When you want to switch, store the current auth before doing your second auth
    $first_app_auth = Podio::$oauth;
    
    // Auth as the second app.
    Podio::authenticate('app', ...);
    
    // Now you can make API requests as the second app
    
    // ...and switch back to the first app
    $second_app_auth = Podio::$oauth;
    
    // Auth as the first app again:
    Podio::$oauth = $first_app_auth;
    
    // Make API requests as the first app again
    

    【讨论】:

    • 嗨 Andreas,我们可以将 Podio::$oauth 值存储到会话中吗?这样可以避免多次应用身份验证。
    • 我们可以使用json_encode来存储会话中的类实例吗?
    • Podio::$oauth 是一个 PodioOAuth 对象,我不建议尝试直接存储它。请参阅此处的 Redis 示例,了解如何在检索时提取属性并正确实例化新的 PodioOAuth 对象:podio.github.io/podio-php/sessions
    猜你喜欢
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    • 2021-06-20
    • 1970-01-01
    • 2016-12-19
    • 2012-06-19
    相关资源
    最近更新 更多