(username, access_token, base64_encode=True)
return auth_string
Generates an IMAP OAuth2 authentication string.

  See https://developers.google.com/google-apps/gmail/oauth2_overview

  Args:
    username: the username (email address) of the account to authenticate
    access_token: An OAuth2 access token.
    base64_encode: Whether to base64-encode the output.

  Returns:
    The SASL argument for the OAuth2 mechanism.
Generates an IMAP OAuth2 authentication string.
Generates an IMAP OAuth2 authentication string .
def GenerateOAuth2String(username, access_token, base64_encode=True):
  """Generates an IMAP OAuth2 authentication string.

  See https://developers.google.com/google-apps/gmail/oauth2_overview

  Args:
    username: the username (email address) of the account to authenticate
    access_token: An OAuth2 access token.
    base64_encode: Whether to base64-encode the output.

  Returns:
    The SASL argument for the OAuth2 mechanism.
  """
  auth_string = 'user=%s\1auth=Bearer %s\1\1' % (username, access_token)
  if base64_encode:
    auth_string = base64.b64encode(auth_string)
  return auth_string
def GenerateOAuth2String ( username , access_token , base64_encode = True ) : auth_string = 'user=%s\1auth=Bearer %s\1\1' % ( username , access_token ) if base64_encode : auth_string = base64 . b64encode ( auth_string ) return auth_string