gmail-api

How do I use oauth2 and refresh tokens with the google api?

喜你入骨 提交于 2019-12-03 03:10:16
So I just spent the last few days trying to figure this out and am asking this question so that I can answer it for other people who are having problems. First, the google documentation is TERRIBLE and uses different oauth2 libraries depending on which of the many google API examples you are looking at. It is often self-contradictory and sometimes straight up has code in it that doesn't work. Oh well. so my questions were basically: how do I use the google api libraries to have my users grant me access to their google accounts? how do I store the oauth2 access tokens that google returns so

API for Inbox by Gmail

久未见 提交于 2019-12-02 21:48:47
Is there any talk of when there will be an API for the new Inbox by Gmail. We would like to integrate into it and would specifically like to tie into the Reminders and Snoozes. Google as a rule does not talk about potential features or release dates. To get informed if a Inbox API is ever released you should subscribe to the Google Developers blog or the Gmail blog . And just as a note the email content of Inbox is already available through the Gmail API . 来源: https://stackoverflow.com/questions/26528778/api-for-inbox-by-gmail

How do I call the gmail api in Spring Boot 2.x using a service account?

三世轮回 提交于 2019-12-02 18:50:14
问题 I have a GSuite service account configured to access corporate user gmail accounts, I have provided it with all of the privileges in the G Suite Admin console including Domain Wide access. I create a service account and now want to use the credentials to send emails on their behalf. Here is my code so far: public void gmailTest(){ log.info("Gmail test"); List<String> SCOPES = new ArrayList<String>(GmailScopes.all()); // List<String> SCOPES = GmailScopes.all(); InputStream resourceAsStream =

Deploying Gmail Apis Project Authentification probleme

白昼怎懂夜的黑 提交于 2019-12-02 17:58:04
问题 when i use the app in local (on executing with visual studio) there is no probleme, but when i deploy my project the authentification doesn't work. the probleme is situated here : string path = HostingEnvironment.MapPath("~/App_Data"); FileDataStore file = new FileDataStore(path); credential =new GoogleWebAuthorizationBroker().AuthorizeAsync( new ClientSecrets { ClientId = "Client_ID", ClientSecret = "Client_Secret" }, Scopes, "me", CancellationToken.None , file ).Result; 回答1: Finally I have

401 ( Unauthorised ) error when using jQuery's $.get and GMail API

房东的猫 提交于 2019-12-02 16:00:50
问题 I'm trying to run jQuery's $.get after having a user log in with the G+ API with javascript, but am getting a 401 ( unauthorised ) error in the browser console. Here is the format of the url I am requesting: https://www.googleapis.com/gmail/v1/users/myusername%40gmail.com/messages?key=%7Bmyborwserapikey%7D I've also tried https://www.googleapis.com/gmail/v1/users/me/messages?key=%7Bmyborwserapikey%7D both are returning the 401 error after logging in. 回答1: Each request to the Gmail API

RFC822 Message-Id in new Gmail API

好久不见. 提交于 2019-12-02 13:19:54
问题 We are trying to set manually the RFC822 Message-Id when sending emails using the gmail api. We have tested but seen that Gmail overrides our value. Do you know if there is a reason for this? Can we do something for this? 回答1: Yes the Message-Id is always set for mail sending to be the proper format for outgoing Gmail mail, the same format as the web interface. What exactly is reason for needing to specify your own value instead of using either the message.id value returned during send for

access delegated mail folder with gmail api

 ̄綄美尐妖づ 提交于 2019-12-02 13:10:25
let's say there are alice@gmail.com and bob@gmail.com. Alice has delegated her account to Bob. When I authenticate with Bob and try to list Alice inbox using the REST interface I get a 403 error: bob@gmail.com does not have privileges to alice@gmail.com mailbox. The URL used to query the inbox is: www.googleapis.com/gmail/v1/users/alice@gmail.com/messages When I use bob@gmail.com (or me) as userId there is no problem. How do I access Alice's account? Greetings You would need to get alice's consent and oauth token to access alice's account through the API--delegation is not supported like it is

reply to thread google-api-ruby-client

北战南征 提交于 2019-12-02 13:08:45
So here's what my code (pretty much) looks like to create a message using the google-api-ruby-client: service ||= Google::Apis::GmailV1::GmailService.new message = RMail::Message.new message.header['To'] = params[:gmail][:to] message.header['From'] = current_user_google_user_id message.header['Subject'] = params[:gmail][:subject] message.header['Subject'] = params[:gmail][:subject] message.body = params[:gmail][:body] service.send_user_message( current_user_google_user_id, upload_source: StringIO.new(message.to_s), content_type: 'message/rfc822', thread_id: params[:gmail][:thread_id] ) It

permanently delete only one gmail message from a thread using a google script

半城伤御伤魂 提交于 2019-12-02 11:32:20
I want to permanently delete a Gmail message inside a thread already in the trash. I merged a few scripts around there, so I can delay and track emails. It works by saving a draft, then the script copy the draft into a new email, send it at the specified time and send the original draft to trash. The problem is that once in a while, the drafts that are in the trash are sent again (i haven't been able to figure out why yet)... As a workaround, I was using the following code that that was originally posted here: delete forever emails 1 : function cleanUp() { var threads = GmailApp.search("in

Gmail Api return Unauthorized client or scope in request

荒凉一梦 提交于 2019-12-02 08:44:14
I have struggled to make this work but did half the job. Actually I can only read messages from Gmail API, If I try to use the gmail.modify Scope I get an error: HttpAccessTokenRefreshError: unauthorized_client: Unauthorized client or scope in request. Here is my code: # init gmail api credentials_path = os.path.join(settings.PROJECT_DIR, 'settings/gmail_credential.json') scopes = ['https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/gmail.modify'] credentials = ServiceAccountCredentials.from_json_keyfile_name(credentials_path, scopes=scopes) delegated_credentials