{"id":15915,"date":"2023-08-30T17:43:16","date_gmt":"2023-08-30T10:43:16","guid":{"rendered":"https:\/\/gcloudvn.com\/?p=15915"},"modified":"2023-11-29T17:28:18","modified_gmt":"2023-11-29T10:28:18","slug":"gmail-api","status":"publish","type":"post","link":"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/","title":{"rendered":"Gmail API \u2013 All you need to know"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">If you&#039;re looking to integrate Gmail into your own applications then <\/span><b>Gmail API<\/b><span style=\"font-weight: 400;\"> just what you need! Gmail is a great and reliable choice for sending emails from the web or your mobile app. Its API is safe and reliable, so your messages will not be sent to Spam. In this article, Gimasys will teach you the basics of Gmail API and detailed instructions on how you can use Gmail API to send emails.<\/span><\/p>\n<p style=\"text-align: justify;\"><b><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15902\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_1.jpg\" alt=\"Gmail API - All you need to know 1\" width=\"600\" height=\"312\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_1.jpg 520w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_1-18x9.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/b><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Gmail_API_la_gi\" >What is Gmail API?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Cach_tich_hop_Gmail_API_vao_App\" >How to integrate Gmail API into App<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Cach_su_dung_Gmail_API\" >How to use Gmail API<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Ket_noi_tai_khoan_Gmail_voi_ung_dung_cua_ban\" >Connect your Gmail account to your app\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Cach_soan_thao_va_gui_email_bang_Gmail_API\" >How to compose and send emails using Gmail API\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Thong_bao_Gmail_webhook\" >Gmail webhook notifications\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Cach_dinh_kem_va_tai_tep_len\" >How to attach and upload files\u00a0<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/gmail-api\/#Tong_ket\" >In conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Gmail_API_la_gi\"><\/span><b>What is Gmail API?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><b>Gmail API<\/b><span style=\"font-weight: 400;\">\u00a0is a set of application programming interfaces (APIs) provided by Google that allow developers to interact programmatically with Gmail. This means developers can build apps, integrations, or tools that can access and manipulate Gmail data, perform actions like sending or receiving emails, and label and create drafts, along with other functions, all in a more efficient way than traditional IMAP.<\/span><\/p>\n<p style=\"text-align: justify;\"><b><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15901 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_2.jpg\" alt=\"Gmail API - All you need to know 2\" width=\"600\" height=\"216\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_2.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api_2-18x6.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/b><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Cach_tich_hop_Gmail_API_vao_App\"><\/span><b>How to integrate Gmail API into App<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The following steps will enable the Gmail API in your project:\u00a0<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li>Step 1:<span style=\"font-weight: 400;\"> Go to API Console.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Step 2: Select a project from the list or create a new project.\u00a0<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Step 3: If the control panel doesn&#039;t open, click the left menu to open it manually.\u00a0<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Step 4: Use the search field to find the API if you don&#039;t see it.\u00a0<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Step 5: Click Enable\u00a0<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Note: Activation will vary depending on the API type. Some APIs will require you to accept their Terms and Conditions before you can activate them. Other APIs may ask you for additional information, such as your contact information or the name of the app being developed.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">If you are asked for additional information, that information will not be shared with anyone other than Google. Google uses this information to understand API usage and to contact you about usage.<\/span><\/p>\n<blockquote><p><strong>Refer:<\/strong> <a href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-thiet-lap-cai-dat-gmail-smtp\/\">Instructions on how to set up Gmail SMTP settings<\/a><\/p><\/blockquote>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Cach_su_dung_Gmail_API\"><\/span><b>How to use Gmail API<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Gmail API can be used to send and receive emails, manage contacts, create labels and filters, etc. To use Gmail API, you need to create a project at Google&#039;s API Console. You also need to enable Gmail API in your project and get credentials for authentication.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">You can then choose the quick start guide or dig through the documentation. The Gmail API is accessed through a client library provided by Google.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Ket_noi_tai_khoan_Gmail_voi_ung_dung_cua_ban\"><\/span><b>Connect your Gmail account to your app\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Before you can access your Gmail accounts, you must authenticate them with the appropriate permissions. This token grants limited access to user resources to the extent the user agreed to as part of the authentication process.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><b><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15903 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api.jpg\" alt=\"Gmail API - All you need to know\" width=\"600\" height=\"375\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/gmail_api-18x12.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/b><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Cach_soan_thao_va_gui_email_bang_Gmail_API\"><\/span><b>How to compose and send emails using Gmail API\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The Gmail API allows you to create and send drafts. A draft is basically an unsent message, it can be created by embedding the MIME message in the base64url string. You can replace the content of the draft with a different MIME encoded message using the update draft method.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The received draft can be used to retrieve the draft content in raw format. The send draft method sends the specified draft.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Thong_bao_Gmail_webhook\"><\/span><b>Gmail webhook notifications\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The Gmail API provides webhook notifications that allow you to monitor the creation, deletion, and labeling of emails and labels in a user&#039;s Gmail account. This saves time and allows you to avoid having to probe users&#039; emails looking for new data.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Notifications for Gmail are sent via Google Cloud Pub, Sub API. This API allows you to receive updates about your Gmail account via webhooks. You will need to create a Cloud Pub\/Sub topic to enable Gmail notifications.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Gmail API webhook notification history is the most important resource component. This is a revised collection of messages in chronological order. This synchronization method stores all modifications to a Gmail account.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Google states that historical changes are typically available for seven days. They are not always available and may not be available for longer periods. Historical resources should only be used for immediate synchronization.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">To synchronize large amounts of data for account users, you can use messages.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The history resource allows you to track changes to your Gmail account, sending viewing requests through the Gmail API. This request will expire after seven days. If you need to track changes beyond this time, additional tracking will be required.\u00a0<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Cach_dinh_kem_va_tai_tep_len\"><\/span><b>How to attach and upload files\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">You can upload files to Gmail through the Gmail API in one of three ways\u00a0<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Uploading is the easiest way to do it. However, it can only upload files up to 5MB in size, and you can&#039;t include metadata.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Multipart uploads are better if you upload smaller files or want to include metadata.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Resumable upload is the third and best option if you have unreliable network conditions and large files.<\/span><\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><b>In conclusion<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><b>Gmail API<\/b><span style=\"font-weight: 400;\"> gives you RESTful access to all the features you normally get with Gmail, including sending and receiving HTML emails, sending and receiving attachments, and performing CRUD operations with messages, drafts, strings and labels.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">You also have full control over your Gmail inbox and can perform specific queries using the web UI&#039;s search capabilities.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Gimasys - Google&#039;s Premier Partner in Vietnam is a provider and consultant on the structure and design of the optimal Cloud solution for you. For technical support, you can contact Gimasys \u2013 Premier Partner of Google in Vietnam at the following information:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Hotline: <\/b><span style=\"font-weight: 400;\">0974 417 099 (HCM) | 0987 682 505 (HN)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Email: <\/b><span style=\"font-weight: 400;\">gcp@gimasys.com<\/span><\/li>\n<\/ul>\n<p style=\"text-align: right;\"><b>Source: <a href=\"https:\/\/gcloudvn.com\/en\/\">Gimasys<\/a><\/b><\/p>","protected":false},"excerpt":{"rendered":"<p>If you&#039;re looking to integrate Gmail into your own applications, the Gmail API is just what you need! Gmail is a great and reliable choice for sending emails from the web or\u2026<\/p>","protected":false},"author":2,"featured_media":15903,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1,134],"tags":[],"class_list":["post-15915","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kienthuc","category-google-workspace","entry","has-media"],"_links":{"self":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts\/15915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/comments?post=15915"}],"version-history":[{"count":0,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts\/15915\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/media\/15903"}],"wp:attachment":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/media?parent=15915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/categories?post=15915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/tags?post=15915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}