Gmail Connector Reference

The following operations allow you to work with the Gmail Connector. Click an operation name to see parameter details and samples on how to use it.


To use the Gmail connector, add the <gmail.init> element in your configuration before carrying out any other Gmail operations.

gmail.init

The Gmail API uses OAuth2 authentication with Tokens. For more information on authentication, go to Authorizing Your App with Gmail.

Parameter Name Description Required
accessToken Value of the Access Token to access the Gmail REST API. Yes
refreshToken Value of the Refresh Token, which generates a new Access Token when the previous one gets expired. Yes
apiUrl The API URL of Gmail (https://www.googleapis.com/gmail). Yes
userId User mail ID. Yes
clientSecret Value of the Client Secret you obtained when you registered your application with the Gmail API. Yes
clientId Value of the Client ID you obtained when you registered your application with Gmail API. Yes
registryPath Registry Path of the connector where the Access Token will be stored (if not provided, the connector stores the Access Token in the connectors/Gmail/accessToken Registry Path). Yes

Sample configuration

<gmail.init>
    <userId>{$ctx:userId}</userId>
    <refreshToken>{$ctx:refreshToken}</refreshToken>
    <clientSecret>{$ctx:clientSecret}</clientSecret>
    <clientId>{$ctx:clientId}</clientId>
    <registryPath>{$ctx:registryPath}</registryPath>
    <accessToken>{$ctx:accessToken}</accessToken>
    <apiUrl>{$ctx:apiUrl}</apiUrl>
</gmail.init>

Drafts

listDrafts

The listDrafts operation lists all drafts in Gmail. See the related API documentation for more information.

Parameter Name Description Required
maxResults Maximum number of messages to return. Yes
pageToken Page token to retrieve a specific page of results in the list. Yes

Sample configuration

<gmail.listDrafts>
    <maxResults>{$ctx:maxResults}</maxResults>
    <pageToken>{$ctx:pageToken}</pageToken>
</gmail.listDrafts>

Sample request

{
    "maxResults":"10"
    "pageToken":"09876536614133772469"
}
readDraft

The readDraft operation retrieves a particular draft email. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the draft email to be retrieve Yes
format The format to return the draft in Yes

Sample configuration

<gmail.readDraft>
    <id>{$ctx:id}</id>
    <format>{$ctx:format}</format>
</gmail.readDraft>

Sample request

{
    "id": "1492984134337920839",
    "format":"raw"
}
deleteDraft

The deleteDraft operation deletes an existing draft. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the draft email to be deleted. Yes

Sample configuration

<gmail.deleteDraft>
    <id>{$ctx:id}</id>
</gmail.deleteDraft>

Sample request

{
    "id":"1491513685150755887"
}
createDraft

The createDraft operation creates a new draft. See the related API documentation for more information.

Parameter Name Description Required
to The email address of the recipient of this email. Yes
subject Subject of the email. Yes
from The email address of the sender of the email. Yes
cc The email addresses of recipients who will receive a copy of this email. Yes
bcc The email addresses of recipients who will privately receive a copy of this email (their email addresses will be hidden from each other). Yes
threadId ID of the thread. Yes
id ID of the email. Yes
messageBody Content of the email. Yes
contentType If the message body is in the format of HTML or if you need to send a rich text then you must give the parameter value as "text/html; charset=UTF-8" otherwise it takes the default value as text/plain. Yes

Sample configuration

<gmail.createDraft>
    <to>{$ctx:to}</to>
    <subject>{$ctx:subject}</subject>
    <from>{$ctx:from}</from>
    <cc>{$ctx:cc}</cc>
    <bcc>{$ctx:bcc}</bcc>
    <id>{$ctx:id}</id>
    <threadId>{$ctx:threadId}</threadId>
    <messageBody>{$ctx:messageBody}</messageBody>
    <contentType>{$ctx:contentType}</contentType>
</gmail.createDraft>

Sample request

{
    "to":"tharis63@hotmail.com",
    "from":"tharis63@gmail.com",
    "subject":"test",
    "messageBody":"Hi hariprasath",
    "cc":"tharis63@outlook.com",
    "bcc":"tharis63@yahoo.com",
    "id":"154b8c77e551c509",
    "threadId":"154b8c77e551c509"
    "contentType":"text/html; charset=UTF-8"
}

Labels

listLabels

The listLabels operation lists all existing labels. See the related API documentation for more information.

Sample configuration

</gmail.listLabels>
readLabel

The readLabel operation gets a label's details. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the label whose details you want to retrieve. Yes

Sample configuration

<gmail.readLabel>
    <id>{$ctx:id}</id>
</gmail.readLabel>

Sample request

{
    "id":"Label_1"
}
deleteLabel

The deleteLabel operation deletes a label. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the label to be deleted. Yes

Sample configuration

<gmail.deleteLabel>
    <id>{$ctx:id}</id>
</gmail.deleteLabel>

Sample request

{
    "id":"57648478394803"
}
createLabels

The createLabels operation creates a new label. See the related API documentation for more information.

Parameter Name Description Required
name The display name of the label. Yes
messageListVisibility The visibility of messages with this label in the message list in the Gmail web interface. Yes
labelListVisibility The visibility of the label in the label list in the Gmail web interface. Yes
type The owner type for the label. Yes
messagesTotal The total number of messages with the label. Yes
messagesUnread The number of unread messages with the label. Yes
threadsTotal The total number of threads with the label. Yes
threadsUnread The number of unread threads with the label. Yes

Sample configuration

<gmail.createLabels>
    <name>{$ctx:name}</name>
    <messageListVisibility>{$ctx:messageListVisibility}</messageListVisibility>
    <labelListVisibility>{$ctx:labelListVisibility}</labelListVisibility>
    <type>{$ctx:type}</type>
    <messagesTotal>{$ctx:messagesTotal}</messagesTotal>
    <messagesUnread>{$ctx:messagesUnread}</messagesUnread>
    <threadsTotal>{$ctx:threadsTotal}</threadsTotal>
    <threadsUnread>{$ctx:threadsUnread}</threadsUnread>
</gmail.createLabels>

Sample request

{
    "name": "TestESB2",
    "threadsUnread": 100,
    "messageListVisibility": "show",
    "threadsTotal": 100,
    "type": "user",
    "messagesTotal": 100,
    "messagesUnread": 100,
    "labelListVisibility": "labelShow"
}
updateLabels

The updateLabels operation updates an existing label. See the related API documentation for more information.

Parameter Name Description Required
name The display name of the label. Yes
messageListVisibility The visibility of messages with this label in the message list in the Gmail web interface. Yes
labelListVisibility The visibility of the label in the label list in the Gmail web interface. Yes
type The owner type for the label. Yes
messagesTotal The total number of messages with the label. Yes
messagesUnread The number of unread messages with the label. Yes
threadsTotal The total number of threads with the label. Yes
threadsUnread The number of unread threads with the label. Yes
id The ID of the label to update. Yes

Sample configuration

<gmail.updateLabels>
    <name>{$ctx:name}</name>
    <messageListVisibility>{$ctx:messageListVisibility}</messageListVisibility>
    <labelListVisibility>{$ctx:labelListVisibility}</labelListVisibility>
    <type>{$ctx:type}</type>
    <messagesTotal>{$ctx:messagesTotal}</messagesTotal>
    <messagesUnread>{$ctx:messagesUnread}</messagesUnread>
    <threadsTotal>{$ctx:threadsTotal}</threadsTotal>
    <threadsUnread>{$ctx:threadsUnread}</threadsUnread>
    <id>{$ctx:id}</id>
</gmail.updateLabels>

Sample request

{
    "id":"426572682792",
    "name": "TestESB2",
    "threadsUnread": 100,
    "messageListVisibility": "show",
    "threadsTotal": 100,
    "type": "user",
    "messagesTotal": 100,
    "messagesUnread": 100,
    "labelListVisibility": "labelShow"
}

Messages

listAllMails

The listAllMails operation lists all messages. See the related API documentation for more information.

Parameter Name Description Required
includeSpamTrash Includes messages from SPAM and TRASH in the results (default: false). Yes
labelIds Only returns messages with labels that match all of the specified label IDs. Yes
maxResults Maximum number of messages to return. Yes
pageToken Page token to retrieve a specific page of results in the list. Yes
q Only returns messages matching the specified query. Supports the same query format as the Gmail search box. Yes

Sample configuration

<gmail.listAllMails>
    <includeSpamTrash>{$ctx:includeSpamTrash}</includeSpamTrash>
    <labelIds>{$ctx:labelIds}</labelIds>
    <maxResults>{$ctx:maxResults}</maxResults>
    <pageToken>{$ctx:pageToken}</pageToken>
    <q>{$ctx:q}</q>
</gmail.listAllMails>

Sample request

{
    "maxResults":"10",
    "includeSpamTrash":"true",
    "pageToken":"00965906535058580458",
    "labelIds":"UNREAD",
    "q":"Jira"
}
readMail

The readMail operation retrieves a message by its ID. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the message to retrieve. Yes
format The format to return. Yes
metadataHeaders When the format is METADATA, only include the headers specified in this property. Yes

Sample configuration

<gmail.readMail>
    <id>{$ctx:id}</id>
    <format>{$ctx:format}</format>
    <metadataHeaders>{$ctx:metadataHeaders}</metadataHeaders>
</gmail.readMail>

Sample request

{
    "id":"14bbb686ba287e1d",
    "format":"minimal"
}
sendMail

The sendMail operation sends a plain message. See the related API documentation for more information.

Parameter Name Description Required
to The email address of the recipient of the message. Yes
subject Subject of the message. Yes
from The email address of the sender of the message. Yes
cc The email addresses of recipients who will receive a copy of this message. Yes
bcc The email addresses of recipients who will privately receive a copy of this message (their email addresses will be hidden). Yes
messageBody The content of the message. Yes
contentType If the message body is in the format of html or need to send a rich text then we must give the parameter value as "text/html; charset=UTF-8" otherwise it takes the default value as text/plain. Yes

Sample configuration

<gmail.sendMail>
    <to>{$ctx:to}</to>
    <subject>{$ctx:subject}</subject>
    <from>{$ctx:from}</from>
    <cc>{$ctx:cc}</cc>
    <bcc>{$ctx:bcc}</bcc>
    <messageBody>{$ctx:messageBody}</messageBody>
    <contentType>{$ctx:contentType}</contentType>
</gmail.sendMail>

Sample request

{
    "to":"ashalya86@gmail.com",
    "subject":"Hello",
    "cc":"vanii@gamil.com",
    "bcc":"elil@gmail.com",
    "messageBody":"Hello! Thank you for contacting us."
    "contentType":"text/html; charset=UTF-8"
}
modifyExistingMessages

The modifyExistingMessages operation modifies an existing message. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the message to modify. Yes
addLabelIds A list of IDs of labels to add to this message. Yes
removeLabelIds A list of IDs of labels to remove from this message. Yes

Sample configuration

<gmail.modifyExistingThreads>
    <id>{$ctx:id}</id>
    <addLabelIds>{$ctx:addLabelIds}</addLabelIds>
    <removeLabelIds>{$ctx:removeLabelIds}</removeLabelIds>
</gmail.modifyExistingThreads>

Sample request

{
    "id":"14ba5cd56fcb61ee",
    "addLabelIds": [
        "Label_33",
        "Label_24"],
    "removeLabelIds": [
        "Label_28",
        "Label_31"]
}
trashMessages

The trashMessages operation sends a message to the trash. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the message to send to trash. Yes

Sample configuration

<gmail.trashMessages>
    <id>{$ctx:id}</id>
</gmail.trashMessages>

Sample request

{
    "id":"4647683792802"
}
unTrashMessages

The unTrashMessages operation removes a message from trash. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the message to untrash. Yes

Sample configuration

<gmail.unTrashMessages>
    <id>{$ctx:id}</id>
</gmail.unTrashMessages>

Sample request

{
    "id":"4647683792802"
}
deleteMessages

The deleteMessages operation permanently deletes a message. The message cannot be recovered after it is deleted. You can use trashMessages instead if you do not want to permanently delete the message. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the message to untrash. Yes

Sample configuration

<gmail.deleteMessages>
    <id>{$ctx:id}</id>
</gmail.deleteMessages>

Sample request

{
    "id":"4647683792802"
}
sendMailWithAttachment

The sendMailWithAttachment operation sends a message with attachments. See the related API documentation for more information.

Parameter Name Description Required
to The email addresses of the recipients of the message. Yes
subject Subject of the message. Yes
cc The email addresses of recipients who will receive a copy of this message. Yes
bcc The email addresses of recipients who will privately receive a copy of this message (their email addresses will be hidden). Yes
fileName A comma-separated list of file names of the attachments you want to include with the message. Yes
filePath A comma-separated list of file paths of the attachments you want to include with the message. Yes
messageBody Content of the message. Yes

Sample configuration

<gmail.sendMailWithAttachment>
    <subject>{$ctx:subject}</subject>
    <to>{$ctx:to}</to>
    <cc>{$ctx:cc}</cc>
    <bcc>{$ctx:bcc}</bcc>
    <messageBody>{$ctx:messageBody}</messageBody>
    <fileName>{$ctx:fileName}</fileName>
    <filePath>{$ctx:filePath}</filePath>
</gmail.sendMailWithAttachment>

Sample request

{
    "subject":"ESB Gmail Connector",
    "to":"hmrajas1990@gmail.com",
    "cc":"hmrajas1990@gmail.com",
    "bcc":"rajjaz@wso2.com",
    "messageBody":"Welcome to ESB ESB Gmail Connector!!!!!",
    "fileName":"/home/rajjaz/Documents/ESB/esb-connector-gmail/src/test/resources/artifacts/ESB/config/smile.png",
    "filePath":"smile.png"
}

Threads

listAllThreads

The listAllThreads operation lists all the existing email threads. See the related API documentation for more information.

Parameter Name Description Required
includeSpamTrash Include messages from SPAM and TRASH in the results (default: false). Yes
labelIds Only returns threads with labels that match all of the specified label IDs. Yes
maxResults Maximum number of messages to return. Yes
pageToken Page token to retrieve a specific page of results in the list. Yes
q Only returns messages matching the specified query. Supports the same query format as the Gmail search box. Yes

Sample configuration

<gmail.listAllThreads>
    <includeSpamTrash>{$ctx:includeSpamTrash}</includeSpamTrash>
    <labelIds>{$ctx:labelIds}</labelIds>
    <maxResults>{$ctx:maxResults}</maxResults>
    <pageToken>{$ctx:pageToken}</pageToken>
    <q>{$ctx:q}</q>
</gmail.listAllThreads>

Sample request

{
    "maxResults":"10",
    "includeSpamTrash":"true",
    "pageToken":"00965906535058580458",
    "labelIds":"UNREAD",
    "q":"Jira"
}
readThread

The readThread operation retrieves an existing thread. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the thread to retrieve. Yes
format The format in which to return the messages in the thread. Yes
metadataHeaders When the format is METADATA, only include the headers specified with this property. Yes

Sample configuration

<gmail.readThread>
    <id>{$ctx:id}</id>
    <format>{$ctx:format}</format>
    <metadataHeaders>{$ctx:metadataHeaders}</metadataHeaders>
</gmail.readThread>

Sample request

{
    "id":"14bbb686ba287e1d",
    "format":"minimal"
}
trashThreads

The trashThreads operation sends a thread to the trash. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the thread to trash. Yes

Sample configuration

<gmail.trashThreads>
    <id>{$ctx:id}</id>
</gmail.trashThreads>

Sample request

{
    "id":"14bbb686ba287e1d"
}
unTrashThreads

The unTrashThreads operation removes a thread from the trash. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the thread to untrash. Yes

Sample configuration

<gmail.unTrashThreads>
    <id>{$ctx:id}</id>
</gmail.unTrashThreads>

Sample request

{
    "id":"14bbb686ba287e1d"
}
modifyExistingThreads

The modifyExistingThreads operation modifies an existing thread. See the related API documentation for more information.

Parameter Name Description Required
id The ID of the thread to modify. Yes
addLabelIds A list of IDs of labels to add to this thread. Yes
removeLabelIds A list of IDs of labels to remove from this thread. Yes

Sample configuration

<gmail.modifyExistingThreads>
    <id>{$ctx:id}</id>
    <addLabelIds>{$ctx:addLabelIds}</addLabelIds>
    <removeLabelIds>{$ctx:removeLabelIds}</removeLabelIds>
</gmail.modifyExistingThreads>

Sample request

{
    "id":"14b31c7af7b778f4",
    "addLabelIds": [
        "Label_33",
        "Label_24"],
    "removeLabelIds": [
        "Label_28",
        "Label_31"]
}

User History

listTheHistory

The listTheHistory operation lists the history of changes to the user's mailbox. See the related API documentation for more information.

Parameter Name Description Required
startHistoryId Returns history records after the specified startHistoryId. Yes
maxResults The maximum number of history records to return. Yes
pageToken Page token to retrieve a specific page of results in the list. Yes

Sample configuration

<gmail.listTheHistory>
    <startHistoryId>{$ctx:startHistoryId}</startHistoryId>
    <labelId>{$ctx:labelId}</labelId>
    <maxResults>{$ctx:maxResults}</maxResults>
    <pageToken>{$ctx:pageToken}</pageToken>
</gmail.listTheHistory>

Sample request

{
    "startHistoryId":"7399652",
    "labelId":"Label_31",
    "maxResults":"10"
}

User Profiles

getUserProfile

The getUserProfile operation lists all details about the user's profile. See the related API documentation for more information.

Sample configuration

<gmail.getUserProfile/>

Sample configuration in a scenario

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the listDrafts operation. The sample request for this proxy can be found in listDrafts sample request. You can use this sample as a template for using other operations in this category.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_listDrafts"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <target>
        <inSequence>
            <property name="maxResults" expression="json-eval($.maxResults)"/>
            <property name="pageToken" expression="json-eval($.pageToken)"/>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <gmail.init>
                <userId>{$ctx:userId}</userId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <registryPath>{$ctx:registryPath}</registryPath>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
            </gmail.init>
            <gmail.listDrafts>
                <maxResults>{$ctx:maxResults}</maxResults>
                <pageToken>{$ctx:pageToken}</pageToken>
            </gmail.listDrafts>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the readLabel operation. The sample request for this proxy can be found in readLabel sample request. You can use this sample as a template for using other operations in this category.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_listLabels"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
        <target>
        <inSequence>
            <property name="id" expression="json-eval($.id)"/>
            <property name="format" expression="json-eval($.format)"/>
            <property name="metadataHeaders" expression="json-eval($.metadataHeaders)"/>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <gmail.init>
                <userId>{$ctx:userId}</userId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <registryPath>{$ctx:registryPath}</registryPath>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
            </gmail.init>
            <gmail.readLabel>
              <id>{$ctx:id}</id>
            </gmail.readLabel>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the listAllMails operation. The sample request for this proxy can be found in listAllMails sample request. You can use this sample as a template for using other operations in this category.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_listAllMails"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="includeSpamTrash" expression="json-eval($.includeSpamTrash)"/>
            <property name="labelIds" expression="json-eval($.labelIds)"/>
            <property name="maxResults" expression="json-eval($.maxResults)"/>
            <property name="pageToken" expression="json-eval($.pageToken)"/>
            <property name="q" expression="json-eval($.q)"/>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <gmail.init>
                <userId>{$ctx:userId}</userId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <registryPath>{$ctx:registryPath}</registryPath>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
            </gmail.init>
            <gmail.listAllMails>
                <includeSpamTrash>{$ctx:includeSpamTrash}</includeSpamTrash>
                <labelIds>{$ctx:labelIds}</labelIds>
                <maxResults>{$ctx:maxResults}</maxResults>
                <pageToken>{$ctx:pageToken}</pageToken>
                <q>{$ctx:q}</q>
            </gmail.listAllMails>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the listAllThreads operation. The sample request for this proxy can be found in listAllThreads sample request. You can use this sample as a template for using other operations in this category.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_listAllThreads"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="includeSpamTrash" expression="json-eval($.includeSpamTrash)"/>
            <property name="labelIds" expression="json-eval($.labelIds)"/>
            <property name="maxResults" expression="json-eval($.maxResults)"/>
            <property name="pageToken" expression="json-eval($.pageToken)"/>
            <property name="q" expression="json-eval($.q)"/>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <gmail.init>
                <userId>{$ctx:userId}</userId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <registryPath>{$ctx:registryPath}</registryPath>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
            </gmail.init>
            <gmail.listAllThreads>
                <includeSpamTrash>{$ctx:includeSpamTrash}</includeSpamTrash>
                <labelIds>{$ctx:labelIds}</labelIds>
                <maxResults>{$ctx:maxResults}</maxResults>
                <pageToken>{$ctx:pageToken}</pageToken>
                <q>{$ctx:q}</q>
            </gmail.listAllThreads>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the listTheHistory operation. The sample request for this proxy can be found in listTheHistory sample request.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_listTheHistory"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="startHistoryId" expression="json-eval($.startHistoryId)"/>
            <property name="labelId" expression="json-eval($.labelId)"/>
            <property name="maxResults" expression="json-eval($.maxResults)"/>
            <property name="pageToken" expression="json-eval($.pageToken)"/>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <gmail.init>
                <userId>{$ctx:userId}</userId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <registryPath>{$ctx:registryPath}</registryPath>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
            </gmail.init>
            <gmail.listTheHistory>
                <startHistoryId>{$ctx:startHistoryId}</startHistoryId>
                <labelId>{$ctx:labelId}</labelId>
                <maxResults>{$ctx:maxResults}</maxResults>
                <pageToken>{$ctx:pageToken}</pageToken>
            </gmail.listTheHistory>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>

The following is a sample proxy service that illustrates how to connect to Gmail with the init operation and use the getUserProfile operation. The sample request for this proxy can be found in listTheProfile sample request.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="gmail_getUserProfile"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="userId" expression="json-eval($.userId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
                <gmail.init>
                    <userId>{$ctx:userId}</userId>
                    <refreshToken>{$ctx:refreshToken}</refreshToken>
                    <clientSecret>{$ctx:clientSecret}</clientSecret>
                    <clientId>{$ctx:clientId}</clientId>
                    <registryPath>{$ctx:registryPath}</registryPath>
                    <accessToken>{$ctx:accessToken}</accessToken>
                    <apiUrl>{$ctx:apiUrl}</apiUrl>
                 </gmail.init>
                 <gmail.getUserProfile/>
             <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <parameter name="serviceType">proxy</parameter>
    <description/>
</proxy>
Top