首页 > 解决方案 > Google 登录 API - 附加范围(Gmail 发送方式)

问题描述

我正在我的应用上实施 Google 登录。使用他们位于此处的分步指南:

https://developers.google.com/identity/sign-in/web/sign-in

对于其他范围,我这样做:

var options = new gapi.auth2.SigninOptionsBuilder(
                        {'scope': 'email https://www.googleapis.com/auth/gmail.compose'});

googleUser = auth2.currentUser.get();
googleUser.grant(options).then(
            function(success){
                console.log(JSON.stringify({message: "success", value: success}));
            },
            function(fail){
                alert(JSON.stringify({message: "fail", value: fail}));
            });

Evreything 正在工作,但我对如何以当前登录用户身份发送电子邮件感到困惑。我需要向 Google 索要刷新令牌吗?如果是这样,怎么做?我假设我没有向 Google 要求刷新令牌,因为我已经授权了范围。我如何以当前登录用户的身份撰写电子邮件?

谢谢,

标签: javascriptphpapigmail

解决方案


推荐阅读