title: Insufficient Permission to modify Gmail labels with via API
body: <p>I am attempting to modify a GMail inbox via their API. </p>
  
  <p>But I am getting the error:</p>
  
  <blockquote>
    <p>HttpError 403 when requesting
    <a href="https://www.googleapis.com/gmail/v1/users/me/labels/SOME_MESSAGE_ID" rel="nofollow noreferrer">https://www.googleapis.com/gmail/v1/users/me/labels/SOME_MESSAGE_ID</a>
    returned "Insufficient Permission"</p>
  </blockquote>
  
  <p>I have used the same OAuth credentials to download my messages. So I know that is working.</p>
  
  <p>I check that the Labels Scope is available.</p>
  
  <p><a href="https://i.stack.imgur.com/uHXMb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uHXMb.png" alt="enter image description here"></a></p>
  
  <p>I can't see anything else that I am doing wrong. <a href="https://developers.google.com/gmail/api/v1/reference/users/labels/update" rel="nofollow noreferrer">The label doc doesn't help.</a></p>
  
  <p><strong>Can any shed some light?</strong></p>
  
  <pre><code>def archive(msg_id):
      creds = None
      if os.path.exists('token.pickle'):
          with open('token.pickle', 'rb') as token:
              creds = pickle.load(token)
      if not creds or not creds.valid:
          if creds and creds.expired and creds.refresh_token:
              creds.refresh(Request())
          else:
              flow = InstalledAppFlow.from_client_secrets_file(
                  'credentials.json', ArchiveScope)
              creds = flow.run_local_server()
          # Save the credentials for the next run
          with open('token.pickle', 'wb') as token:
              pickle.dump(creds, token)
  
      service = build('gmail', 'v1', credentials=creds)
  
      msg_labels = {'removeLabelIds': ['INBOX'], 'addLabelIds': ['MyLabel']}
  
      service.users().labels().update(userId='me', id=msg_id, body=msg_labels).execute()
  
      print('Message ID: %s' % msg_id)
  </code></pre>