TeamsUserCredential.LoginAsync Method

Definition

Overloads

LoginAsync(String)

Popup login page to get user's access token with specific scopes.

LoginAsync(String[])

Popup login page to get user's access token with specific scopes.

LoginAsync(String)

Popup login page to get user's access token with specific scopes.

public System.Threading.Tasks.Task LoginAsync(string scopes);
member this.LoginAsync : string -> System.Threading.Tasks.Task
Public Function LoginAsync (scopes As String) As Task

Parameters

scopes
String

The string of Microsoft Token scopes of access. Default value is .default.

Returns

Exceptions

When simple auth server failed to exchange access token.

When runtime is not in browser enviroment.

When failed to login with unknown error.

When user canceled or failed to consent.

Examples

For example:

await teamsUserCredential.LoginAsync("User.Read"); // single scopes using string
await teamsUserCredential.LoginAsync("User.Read Calendars.Read"); // multiple scopes using string

Remarks

Only works in Teams client app. User will be redirected to the authorization page to login and consent.

Applies to

LoginAsync(String[])

Popup login page to get user's access token with specific scopes.

public System.Threading.Tasks.Task LoginAsync(string[] scopes);
member this.LoginAsync : string[] -> System.Threading.Tasks.Task
Public Function LoginAsync (scopes As String()) As Task

Parameters

scopes
String[]

The array of Microsoft Token scopes of access. Default value is [.default].

Returns

Exceptions

When simple auth server failed to exchange access token.

When runtime is not in browser enviroment.

When failed to login with unknown error.

When user canceled or failed to consent.

Examples

For example:

await teamsUserCredential.LoginAsync(new string[] { "User.Read" }); // single scope using string array
await teamsUserCredential.LoginAsync(new string[] { "User.Read Calendars.Read" }); //  multiple scopes using string array

Remarks

Only works in Teams client APP. User will be redirected to the authorization page to login and consent.

Applies to