Fetches an OAuth 2 token.

def get_token(code, token_service, client_id, client_secret, redirect_uri,
              grant_type):
  """Fetches an OAuth 2 token."""
  data = {
      'code': code,
      'client_id': client_id,
      'client_secret': client_secret,
      'redirect_uri': redirect_uri,
      'grant_type': grant_type,
  }
  # Get the default http client
  resp = requests.post(token_service, data, verify=False)
  return resp.json()