title: "Insufficient Permissions" Error with Google Appscripts
body: <p>I get following error when I try to create draft using google appscripts</p>
  
  <pre><code>{
   "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "insufficientPermissions",
      "message": "Insufficient Permission"
     }
    ],
    "code": 403,
    "message": "Insufficient Permission"
   }
  }
  </code></pre>
  
  <p>I enabled GMAIL api service in resource --> Advanced google services. I am using the following end point to create the draft. </p>
  
  <p><a href="https://www.googleapis.com/gmail/v1/users/me/drafts" rel="nofollow">https://www.googleapis.com/gmail/v1/users/me/drafts</a></p>
  
  <p>I am not sure if I need to enable any other api to make this work. Would appreciate any help to debug this issue</p>
  
  <p>I am making the api as shown below:</p>
  
  <pre><code>function createDraft(tid,Subject,Body,fromEmail,toEmail,ccEmail) {
  
  var boundary = "ABDADASFDSBCCCADSAD" + (new Date()).getTime().toString();
  
  SendSubject = "Subject:" + Subject
  
  raw = SendSubject + "\r\n" + 
  "From: " + fromEmail +  "\r\n" +
  "To: " + toEmail +  "\r\n" +
  "Cc: " + ccEmail +  "\r\n" +
  "Content-Type: multipart/alternative; boundary=" + boundary  + "\r\n" + "\r\n" + 
  "--" + boundary + "\r\n" +
  "Content-Type: text/html; charset=UTF-8" + "\r\n" + 
  "Content-Transfer-Encoding: quoted-printable"  + "\r\n" + "\r\n" + 
    Body + "\r\n" + "\r\n" + 
   "--" + boundary + "--"
  //var draftBody = Utilities.base64Encode(raw, Utilities.Charset.US_ASCII).replace(/\//g,'_').replace(/\+/g,'-')
  
  var draftBody = Utilities.base64EncodeWebSafe(raw,  Utilities.Charset.UTF_8)
  
  
  var params = {method:"post",
                  contentType: "application/json",
                  headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken(),  "Reply-To": "naveen@skedool.it"},
                  muteHttpExceptions:true,
                  payload:JSON.stringify({
                    "message": {
                      "raw": draftBody,
                      "threadId" : tid
                    }
                  })
                 };
  
   var resp = UrlFetchApp.fetch("https://www.googleapis.com/gmail/v1/users/me/drafts", params);
   //Logger.log(resp);
  
  
  return resp
  
  }
  </code></pre>