You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ballerina Gmail Connector provides the capability to send, read and delete emails through the Gmail REST API. It also provides the ability to read, trash, untrash and delete threads, ability to get the Gmail profile and mailbox history, etc. The connector handles OAuth 2.0 authentication.
5
+
Ballerina Gmail Connector provides the capability to send, read and delete emails through the Gmail REST API.
6
+
It also provides the ability to read, trash, untrash and delete threads, ability to get the Gmail profile and
7
+
mailbox history, etc. The connector handles OAuth 2.0 authentication.
6
8
7
9
The following sections provide you with information on how to use the Ballerina Gmail Connector.
8
10
@@ -15,56 +17,66 @@ The following sections provide you with information on how to use the Ballerina
15
17
16
18
| Ballerina Language Versions | Gmail API Version |
The `wso2/gmail` module contains operations to send emails in Text and HTML formats with attachments and inline images. It supports searching and reading emails in Gmail using Gmail filters. The module also supports trashing, untrashing, deleting, and modifying emails.
26
+
The `ballerinax/googleapis.gmail` module contains operations to send emails in Text and HTML formats with
27
+
attachments and inline images. It supports searching and reading emails in Gmail using Gmail filters. The module
28
+
also supports trashing, untrashing, deleting, and modifying emails.
25
29
26
30
#### Working with Threads
27
31
28
-
The `wso2/gmail` module contains operations to read, search, trash, untrash, modify and delete email threads in Gmail.
32
+
The `ballerinax/googleapis.gmail` module contains operations to read, search, trash, untrash, modify and delete
33
+
email threads in Gmail.
29
34
30
35
#### Working with Drafts
31
36
32
-
The `wso2/gmail` module contains operations to search, read, delete, create, update and send drafts in Gmail.
37
+
The `ballerinax/googleapis.gmail` module contains operations to search, read, delete, create, update and send
38
+
drafts in Gmail.
33
39
34
40
#### Working with Labels
35
41
36
-
The `wso2/gmail` module containes operations to list, read, create, update and delete labels in Gmail.
42
+
The `ballerinax/googleapis.gmail` module contains operations to list, read, create, update and delete labels in Gmail.
37
43
38
44
#### Working with User Profiles
39
45
40
-
The `wso2/gmail` module contains operations to get Gmail user profile details.
46
+
The `ballerinax/googleapis.gmail` module contains operations to get Gmail user profile details.
41
47
42
48
#### Working with Mailbox History
43
49
44
-
The `wso2/gmail` module contains operations to lists the history of changes to the user's mailbox.
50
+
The `ballerinax/googleapis.gmail` module contains operations to lists the history of changes to the user's mailbox.
45
51
46
52
## Getting Started
47
53
48
54
## Sample
49
-
First, import the `wso2/gmail` module into the Ballerina project.
55
+
First, import the `ballerinax/googleapis.gmail` module into the Ballerina project.
50
56
```ballerina
51
-
import wso2/gmail;
57
+
import ballerinax/googleapis.gmail;
52
58
```
53
-
Instantiate the connector by giving authentication details in the Gmail client config, which has built-in support for OAuth 2.0. Gmail uses OAuth 2.0 to authenticate and authorize requests. The Gmail connector can be minimally instantiated in the Gmail client config using the Access Token or by using the Client ID, Client Secret and Refresh Token.
59
+
Instantiate the connector by giving authentication details in the Gmail client config, which has built-in support
60
+
for OAuth 2.0. Gmail uses OAuth 2.0 to authenticate and authorize requests. The Gmail connector can be minimally
61
+
instantiated in the Gmail client config using the Access Token or by using the Client ID, Client Secret and Refresh Token.
54
62
55
63
**Obtaining Tokens to Run the Sample**
56
64
57
-
1. Visit [Google API Console](https://console.developers.google.com), click **Create Project**, and follow the wizard to create a new project.
65
+
1. Visit [Google API Console](https://console.developers.google.com), click **Create Project**, and follow the wizard
66
+
to create a new project.
58
67
2. Go to **Credentials -> OAuth Consent Screen**, enter a product name to be shown to users, and click **Save**.
59
68
3. On the **Credentials** tab, click **Create Credentials** and select **OAuth Client ID**.
60
-
4. Select an application type, enter a name for the application, and specify a redirect URI (enter https://developers.google.com/oauthplayground if you want to use
69
+
4. Select an application type, enter a name for the application, and specify a redirect URI
70
+
(enter https://developers.google.com/oauthplayground if you want to use
61
71
[OAuth 2.0 Playground](https://developers.google.com/oauthplayground) to receive the Authorization Code and obtain the
62
72
Access Token and Refresh Token).
63
73
5. Click **Create**. Your Client ID and Client Secret will appear.
64
-
6. In a separate browser window or tab, visit [OAuth 2.0 Playground](https://developers.google.com/oauthplayground). Click on the `OAuth 2.0 Configuration`
65
-
icon in the top right corner and click on `Use your own OAuth credentials` and provide your `OAuth Client ID` and `OAuth Client Secret`.
74
+
6. In a separate browser window or tab, visit [OAuth 2.0 Playground](https://developers.google.com/oauthplayground).
75
+
Click on the `OAuth 2.0 Configuration` icon in the top right corner and click on `Use your own OAuth credentials` and
76
+
provide your `OAuth Client ID` and `OAuth Client Secret`.
66
77
7. Select the required Gmail API scopes from the list of API's, and then click **Authorize APIs**.
67
-
8. When you receive your authorization code, click **Exchange authorization code for tokens** to obtain the refresh token and access token.
78
+
8. When you receive your authorization code, click **Exchange authorization code for tokens** to obtain the
79
+
refresh token and access token.
68
80
69
81
You can now enter the credentials in the Gmail client config.
70
82
```ballerina
@@ -115,7 +127,8 @@ if (sendMessageResponse is [string, string]) {
115
127
}
116
128
```
117
129
118
-
The `readMessage` remote function reads messages. It returns the `Message` object when successful or an `error` when unsuccessful.
130
+
The `readMessage` remote function reads messages. It returns the `Message` object when successful or an `error`
131
+
when unsuccessful.
119
132
120
133
```ballerina
121
134
var response = gmailClient->readMessage(userId, <@untainted>messageId);
0 commit comments