我可以通过GmailApi
的{{1}}迅速获得用户电子邮件的许可。但是我发现很难实现它。使用googleapi
作为软件包,我确定我不必从普通的GmailApi
获取用户信息和邮件,因此我做了一些研究,并遵循了其他http
上的一些教程和主题,与随包导入的标签有关
googleapis
我能够以此获得用户邮件许可,并将httpClient初始化为登录用户。
import 'package:googleapis/gmail/v1.dart'
show
Label, Profile, GmailApi, Filter, Message, UsersResourceApi, Thread, BatchDeleteMessagesRequest, BatchDeleteMessagesRequest, Draft, UsersMessagesAttachmentsResourceApi;
//tags I mentioned in the paragraph above.
我找不到使用上述代码的方法,所以我尝试了这种方法,我认为这是正确的方法,但是没有步骤或文档可以使它起作用,这与我在{{1 }}和final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn(
scopes: [
GmailApi.MailGoogleComScope,
GmailApi.GmailComposeScope,
GmailApi.MailGoogleComScope,
GmailApi.GmailInsertScope,
GmailApi.GmailLabelsScope,
GmailApi.GmailMetadataScope,
GmailApi.GmailModifyScope,
GmailApi.GmailReadonlyScope,
GmailApi.GmailSendScope,
GmailApi.GmailSettingsSharingScope,
]
);
final httpClient = googleSignIn.currentUser.authHeaders;
class GmailApi{
static const MailGoogleComScope = "https://mail.google.com/";
static const GmailComposeScope = "https://www.googleapis.com/auth/gmail.compose";
static const GmailInsertScope = "https://www.googleapis.com/auth/gmail.insert";
static const GmailLabelsScope = "https://www.googleapis.com/auth/gmail.labels";
static const GmailMetadataScope = "https://www.googleapis.com/auth/gmail.metadata";
static const GmailModifyScope = "https://www.googleapis.com/auth/gmail.modify";
static const GmailReadonlyScope = "https://www.googleapis.com/auth/gmail.readonly";
static const GmailSendScope = "https://www.googleapis.com/auth/gmail.send";
static const GmailSettingsBasicScope = "https://www.googleapis.com/auth/gmail.settings.basic";
static const GmailSettingsSharingScope = "https://www.googleapis.com/auth/gmail.settings.sharing";
final commons.ApiRequester _requester;
UsersResourceApi get users => new UsersResourceApi(_requester);
GmailApi(http.Client client,
{core.String rootUrl = "https://www.googleapis.com/",
core.String servicePath = "gmail/v1/users/"})
: _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_AGENT);
}
。
这仅将值显示为null。我在做什么错了?
DriveApi