Azure Device Flow
Azure AD Device Token authentication
This article is the sample showing Gosip custom auth with AAD Device Token Authorization.
If you want users to sign in interactively, the best way is through device token authentication. This authentication flow passes the user a token to paste into a Microsoft sign-in site, where they then authenticate with an Azure Active Directory (AAD) account. This authentication method supports accounts that have multi-factor authentication enabled, unlike standard username/password authentication.
Azure App registration
1. Create or use existing app registration
2. Make sure that the app is configured to support device flow
Authentication settings
Public client/native (mobile & desktop)
Suggested Redirect URIs for public clients (mobile, desktop) - https://login.microsoftonline.com/common/oauth2/nativeclient - checked
Default client type - Yes - for Device code flow, learn more
App permissions
Azure Service Management :: user_impersonation
SharePoint :: based on your application requirements
etc. based on application needs
Auth configuration and usage
When started the application interacts with user using device login.
After opening the link, providing device code and authenticating in browser the app is ready for communication with your SharePoint site.
The strategy caches auth token in the context of the AAD ClientID. As a result, you won't see the sign in message. If it's not the desired behavior .CleanTokenCache()
method can be called to clean the local cache.
Note, that the technique is mostly applicable when user interaction is assumed. Usage of that auth approach in the headless scenarios is not the best as it can lead "stuck" application if no-one expects sign in interaction.
Last updated