title: How to set authorization for sending mail through Gmail Api in Javascript?
body: <p>I am trying to send mail using Gmail Api in javascript but i am getting 401 error (Login Required). My application is already authorized, I have an access token.</p>
  
  <p>This is my piece of code that i am trying to run:</p>
  
  <pre><code> gapi.client.load('gmail', 'v1', 
   var email = ''{my mail content};
  
  var sendRequest = gapi.client.gmail.users.messages.send({
  'userId': 'me',
  'resource': {
    'raw': window.btoa(email).replace(/\+/g, '-').replace(/\//g, '_')
  }
  
  });
  return sendRequest.execute(callback);
  });
  </code></pre>
  
  <p>Please help me what to do? Thanks in advance.</p>