我正在尝试使用Android应用程序访问Gmail API.我已成功请求并使用所有可用范围组合接收了访问令牌.但似乎每次我实际尝试使用Gmail API命令时,我都会得到一个403 exception reading: Access not configured please use Google developers console to activate the 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 …
Run Code Online (Sandbox Code Playgroud) android google-oauth google-schemas google-oauth-java-client gmail-api
我在解码使用Gmail API收到的电子邮件的邮件正文时遇到严重问题.我想抓取消息内容并将内容放在div中.我正在使用base64解码器,我知道它不会解码编码不同的电子邮件,但我不知道如何检查电子邮件以决定使用哪个解码器 - 说明它们是utf-8编码的电子邮件已成功解码base64解码器,但不是utf-8解码器.
我已经研究了几天的电子邮件解码,而且我已经了解到我在这里的联盟有点不合适.我之前没有做过很多关于电子邮件编码的工作.这是我用于获取电子邮件的代码:
gapi.client.load('gmail', 'v1', function() {
var request = gapi.client.gmail.users.messages.list({
labelIds: ['INBOX']
});
request.execute(function(resp) {
document.getElementById('email-announcement').innerHTML = '<i>Hello! I am reading your <b>inbox</b> emails.</i><br><br>------<br>';
var content = document.getElementById("message-list");
if (resp.messages == null) {
content.innerHTML = "<b>Your inbox is empty.</b>";
} else {
var encodings = 0;
content.innerHTML = "";
angular.forEach(resp.messages, function(message) {
var email = gapi.client.gmail.users.messages.get({
'id': message.id
});
email.execute(function(stuff) {
if (stuff.payload == null) {
console.log("Payload null: " + message.id);
}
var header = "";
var …
Run Code Online (Sandbox Code Playgroud) 我应该如何在Python 2.7中保护我的密码?getpass.getpass()
方法不起作用.在我运行代码时,密码是可见的.
我做过这样的事情:
M = imaplib.IMAP4_SSL('imap.gmail.com')
try:
emailid=input("what is your email id: ")
password=getpass.getpass("enter your password: ")
M.login(emailid,password)
Run Code Online (Sandbox Code Playgroud) 我在Openshift上部署了Web服务。目前,我正在开发一种使用我的Gmail帐户在特定时间发送自动电子邮件的方法。
因此,我已经记录了自己两到三天,得出的结论是我有两个选择:
1)使用JavaMail库。2)使用Gmail API。
对于第一个选项,我使用了以下类:
public class EmailSenderService {
private final Properties properties = new Properties();
private String password = "*******";
private Session session;
private void init() {
//ssl
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("eu***@gmail.com",password);
}
});
}
public void sendEmail(){
init();
//ssl
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("eu***@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("c***6@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler," +
"\n\n No spam …
Run Code Online (Sandbox Code Playgroud) email jakarta-mail google-api-java-client google-oauth gmail-api
我试图让我refresh_token
生成一个新的access_token
. 我正在使用请求模块发出请求,但它返回一个错误,内容类似于“找不到页面”。
var request = require('request');
module.exports = function(callback){
console.log('here');
request('https://googleapis.com/oauth2/v3/token?client_id=NotID&client_secret=Not_Secret&refresh_token=NotRefresh&grant_type=refresh_token', function (error, response, body) {
if (!error && response.statusCode == 200) {
callback(response)
}
});
}
Run Code Online (Sandbox Code Playgroud) @Override
protected List< String > doInBackground( Void... params )
{
try
{
//This line below is the cause of the insufficient permissions error
ListMessagesResponse messagesWithLabels = mService.users().messages().list("me").setQ("label:inbox").execute();
/*for( Message m : messagesWithLabels.getMessages( ) )
{
if( m.size( ) > MAXSIZE )
{
List<MessagePartHeader> headers = m.getPayload( ).getHeaders( );
for ( MessagePartHeader header : headers )
{
if ( header.getName( ).equals("From") || header.getName().equals("Date")
|| header.getName().equals("Subject") || header.getName().equals("To")
|| header.getName().equals("CC")) {
messageDetails.put( header.getName( ).toLowerCase( ), header.getValue( ) );
}
}
messageDetails.put("snippet", m.getSnippet()); …
Run Code Online (Sandbox Code Playgroud) 我的代码应该在我的收件箱中收到一条消息,检查它是否有链接,然后从电子邮件中提取链接然后将其删除.
message = gmail_service.users().messages().get(userId='me', id=thread['id'], format='raw').execute() #get message using thread id
msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII'))
msg = email.message_from_string(msg_str)
for part in msg.walk():
msg.get_payload()
if part.get_content_type() == 'text/html':
mytext = base64.urlsafe_b64decode(part.get_payload().encode('UTF-8'))
html = BeautifulSoup(mytext)
for link in html.find_all('a'):
mylink = link.get('href')
print mylink
try:
service.users().messages().trash(userId='me', id=thread['id']).execute()
print 'Message with id: %s trashed successfully.' % msg_id
except errors.HttpError, error:
print 'Could not trash ' + thread['id'] + ': %s' % error
Run Code Online (Sandbox Code Playgroud)
我在代码中定义的范围是.modify
应该给我,我需要垃圾邮件的权限,没有失败.为什么我收到错误:
<HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/me/messages/147d8c9a6348e437/trash?alt=json returned "Insufficient …
Run Code Online (Sandbox Code Playgroud) 我正在尝试验证我的凭据以访问GMail API.以前我使用run()
OAuth2中的方法和代码执行credentials = tools.run(flow, STORAGE, http=http)
此操作,但现在这是一个不推荐使用的方法.我现在正在使用该run_flow()
方法来验证我的凭据.
import httplib2
import argparse
from apiclient import errors
from apiclient.discovery import build
from oauth2client import tools
from oauth2client.file import Storage
from oauth2client.client import flow_from_clientsecrets
CLIENT_SECRET_FILE = 'your_client_secret.json'
OAUTH_SCOPE = 'https://www.googleapis.com/auth/gmail.modify'
STORAGE = Storage('gmail.storage')
flow = flow_from_clientsecrets(CLIENT_SECRET_FILE, scope=OAUTH_SCOPE)
http = httplib2.Http()
credentials = STORAGE.get()there are credentials, no reauth is needed
#parser = argparse.ArgumentParser(parents=[tools.argparser])
#flags = parser.parse_args() #Put your arguments in the parenthesis
if credentials is None or credentials.access_token_expired:
credentials …
Run Code Online (Sandbox Code Playgroud) oauth-2.0 oauth2client google-oauth google-api-python-client gmail-api
我正在关注https://developers.google.com/gmail/api/guides/push 上给出的 Gmail API 推送通知指南。但是,当我尝试从 API 资源管理器创建新手表时,它给出了以下响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"
}
],
"code": 400,
"message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"
}
Run Code Online (Sandbox Code Playgroud)
}
我的要求如下:
POST https://www.googleapis.com/gmail/v1/users/myemailaddress/watch?key={YOUR_API_KEY}
{
"labelIds": [
"INBOX"
],
"topicName": "projects/my-project-name/topics/my-topic-name"
}
Run Code Online (Sandbox Code Playgroud)
似乎在 Google API 端进行了错误的验证检查。还有其他人面临这个问题吗?
gmail-api ×8
google-oauth ×6
android ×2
email ×2
debugging ×1
decoding ×1
jakarta-mail ×1
javascript ×1
node.js ×1
oauth ×1
oauth-2.0 ×1
oauth2client ×1
post ×1
python ×1
python-2.7 ×1