首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Horde Gmail OAuth2身份验证失败

Horde Gmail OAuth2身份验证失败
EN

Stack Overflow用户
提问于 2021-02-19 23:28:25
回答 1查看 194关注 0票数 2

问题:

当为Horde_Imap_Client_Socket类使用以下参数时,我使用Horde和googles OAuth2登录到用户IMAP。

代码语言:javascript
复制
"username" : "example@gmail.com"
"password" : "XOAUTH2"
"hostspec" : "imap.gmail.com"
"port" : 993
"secure" : "ssl"
"timeout" : 20
"context" :
    "ssl" :
    "verify_peer" : true
    "verify_peer_name" : true
"xoauth2_token" : "{INSERT GOOGLE ACCESS TOKEN HERE}"

我得到了这个错误。

Authentication failed.

添加"debug" => "php://output"会给出下面的输出。

代码语言:javascript
复制
------------------------------ >> Fri, 19 Feb 2021 19:30:27 +0000 >> Connection to: imap://imap.gmail.com:993/ >> Server connection took 0.1738 seconds. 
S: * OK Gimap ready for requests from 24.231.213.106 t22mb47308959jai 
C: 1 CAPABILITY 
S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH 
S: 1 OK Thats all she wrote! t22mb47308959jai >> Command 1 took 0.0652 seconds. 
C: 2 AUTHENTICATE XOAUTH2 {REDACTED (TOKEN)} 
C: S: 2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure) >> Command 2 took 0.2507 seconds. 
C: 3 AUTHENTICATE PLAIN [INITIAL CLIENT RESPONSE (username: {REDACTED})] 
S: 3 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure) >> Command 3 took 0.2358 seconds. 

我假设我在下面的代码中做了一些错误的事情,因为我对部落没有太多的经验。

代码:

代码语言:javascript
复制
$credentials = json_decode($provider['credentials'], true);
$params = [
    'username' => $user,
    'password' => "XOAUTH2",
    'hostspec' => $host,
    'port' => $port,
    'secure' => $ssl_mode,
    'timeout' => (int) $this->config->getSystemValue('app.mail.imap.timeout', 20),
    'context' => [
        'ssl' => [
            'verify_peer' => $this->config->getSystemValueBool('app.mail.verify-tls-peer', true),
            'verify_peer_name' => $this->config->getSystemValueBool('app.mail.verify-tls-peer', true),
        ],
    ],
    'xoauth2_token' => new \Horde_Imap_Client_Password_Xoauth2($user, $credentials['access_token'])->getPassword()
];
$this->client = new \Horde_Imap_Client_Socket($params);
try {
    $this->client->login();
} catch (Horde_Imap_Client_Exception $e) {
    throw new ServiceException(
        "Could not connect to IMAP host $host:$port: " . $e->getMessage(),
        (int) $e->getCode(),
        $e
    );
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-23 13:56:19

这最终导致了范围在实际授权url上的问题,而不仅仅是在Google Cloud控制台上的API客户端设置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66280393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档