BearerToken Property  

Gets and sets the OAuth 2.0 bearer token for the current user.


object.BearerToken [= token ]


The BearerToken property specifies the OAuth 2.0 bearer token used to authenticate the user. This property is used as the default value for the Connect method if the token is not provided as an parameter.

Assigning a value to this property will change the current authentication method to use OAuth 2.0 if necessary.

You should only use an OAuth 2.0 authentication method if you understand the process of how to request the access token. Obtaining an bearer token requires registering your application with the mail service provider (e.g.: Microsoft or Google), getting a unique client ID associated with your application and then requesting the token using the appropriate scope for the service. Obtaining the initial token will typically involve interactive confirmation on the part of the user, requiring they grant permission to your application to access their mail account.

Your application should not store an OAuth 2.0 bearer token for later use. They have a relatively short lifespan, typically about an hour, and are designed to be used with that session. You should specify offline access as part of the OAuth 2.0 scope if necessary and store the refresh token provided by the service. The refresh token has a much longer validity period and can be used to obtain a new bearer token when needed.

If the current authentication method does not use OAuth 2.0, this property will return an empty string and you should check the value of the Password property to obtain the current user's password. Refer to the AuthType property for more information on the available authentication methods.

Data Type


See Also

AuthType Property, Password Property, UserName Property, Connect Method