Using Android GoogleSignIn with GmailScopes.GMAIL_SEND (gmail api)(将Android GoogleSignIn与GmailScope配合使用。GMAIL_Send(Gmail API))
本文介绍了将Android GoogleSignIn与GmailScope配合使用。GMAIL_Send(Gmail API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用GoogleSignIn并使用Android内部电子邮件地址(Gmail)发送电子邮件
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
//.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.requestScopes(new Scope(GmailScopes.GMAIL_SEND) )
.build();
// Build a GoogleSignInClient with the options specified by gso.
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
dependencies {
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
implementation 'com.google.apis:google-api-services-gmail:v1-rev83-1.23.0'
// ...
}
我设置了Google控制台API密钥,以使用Gmail,并且OAuth添加了我的SH1。
- 我不知道将API密钥放在应用程序中的什么位置
- 使用Google登录时无需 即可正常工作
.questScope(新作用域(GmailScope.GMAIL_Send))
但当我添加它时,它永远挂起。
推荐答案
在Gmail快速入门指南中,您有:
private static final String TOKENS_DIRECTORY_PATH = "tokens";
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
.
.
.
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT,Context context, String personId) throws IOException {
// Load client secrets.
InputStream in = GmailQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
if (in == null) {
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
}
您需要下载redentials.json并放在这里:
如何在Android中集成Gmail API,请查看以下完整答案: Use Gmail api for send mail via Android app
这篇关于将Android GoogleSignIn与GmailScope配合使用。GMAIL_Send(Gmail API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:将Android GoogleSignIn与GmailScope配合使用。GMAIL_Send(Gmail API)
基础教程推荐
猜你喜欢
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01