大佬教程收集整理的这篇文章主要介绍了使用Android的Gmail API访问,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
不用说API被激活,并且使用正确的包名称& sha1代码.相同的客户端ID适用于Google Plus功能.
有任何人遇到此问题或成功连接到Android的Gmail api?
谢谢
这是日志:
09-04 21:40:54.014: W/System.err(26717): com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden 09-04 21:40:54.014: W/System.err(26717): { 09-04 21:40:54.014: W/System.err(26717): "code" : 403,09-04 21:40:54.014: W/System.err(26717): "errors" : [ { 09-04 21:40:54.014: W/System.err(26717): "domain" : "usageLimits",09-04 21:40:54.014: W/System.err(26717): "message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project.",09-04 21:40:54.014: W/System.err(26717): "reason" : "accessnotConfigured" 09-04 21:40:54.014: W/System.err(26717): } ],09-04 21:40:54.014: W/System.err(26717): "message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project." 09-04 21:40:54.014: W/System.err(26717): }
除了API API和Gmail API,是否还需要在API控制台中启用任何其他API?
编辑:
我发现使用基于WebView的身份验证将导致一个访问令牌,这将允许Gmail API访问,但这不是一个有效的解决方案,因为令牌是短暂的.至于现在,GoogleAuthUtil将会授予一个令牌,但它的权限不足以使用Gmail API.
任何人都能够将Android与Gmail API连接起来,并希望分享?
EDIT2:
这是我在做什么的片段
获取令牌:
token = GoogleAuthUtil.getToken(MainActivity.this,Plus.AccountApi.getAccountName(mGoogleApiClient),scopE);
GoogleCredential credential = new GoogleCredential().setAccessToken(token); JsonFactory jsonFactory = new JacksonFactory(); httpTransport httpTransport = new NethttpTransport(); service = new Gmail.builder(httpTransport,jsonFactory,credential).setApplicationName("GmailApiTP").build(); ListmessagesResponse messagesRespose; List<message> m = null; ArrayList<String> ids = new ArrayList<String>(); ids.add("INBox"); try { messagesRespose = service.users().messages().list("me").setLabelIds(ids).setQ("From: something") .execute(); m = messagesRespose.getmessages(); } catch (IOException E) { e.printStackTrace(); }
使用Gmail API服务时就会被捕获.此外,我已经尝试清除令牌,并要求一个新的令牌相同的结果.
确认您正确遵循以下指示:
https://developers.google.com/accounts/docs/OAuth2
(应为“安装应用”等)
你可以从开发者控制台发布oauth客户端信息吗? (类型和其他非机密信息等)
以上是大佬教程为你收集整理的使用Android的Gmail API访问全部内容,希望文章能够帮你解决使用Android的Gmail API访问所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。