I'm trying to get all the messages in a thread in sent items. In the code below, I can get all the sent threads in variable 'mails' as **[GmailThread GmailThread ..]**. Also mails[0].getId() gives threadId of mails[0]. 

```
var mails = GmailApp.search('in:sent');
Logger.log(mails[0].getMessages());

```

But mails[0].getMessages() returns run time error as 

```
Access denied: : Missing access token for authorization. Request: MailboxService.GetThread.

```

Here's the scopes I've included.

```
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/gmail.addons.current.message.action",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.modify",
"https://mail.google.com/"
]

```

Now what I want is to get all the messages in mails[0].