OneDrive / onedrive-sdk-dotnet-msa-auth-adapter

Other
26 stars 22 forks source link

server/daemon type authentication #24

Closed lockelost closed 7 years ago

lockelost commented 7 years ago

Hi, I need to run my client in service/daemon mode, which means no user interaction is possible. Here in Azure sample, it says we can use AppId and AppKey for this kind of application. https://github.com/Azure-Samples/active-directory-dotnet-daemon

Are you considering support for this type of applications?

Best,

cdmayer commented 7 years ago

As I answered in the other repository this is not currently supported but could definitely be added. I'll leave this issue open and classified as an Enhancement for future consideration.

lockelost commented 7 years ago

Hi 'cdmayer', I created the Pull request for this very simple but working AuthProvider for 'Daemon' type applications.

Users can use like this.

string clientid = "[Your Application ID]"; string appKey = "[Your Application Key]"; string tenant = "[Your tenant name, usually a domain name for your Office365 service. Like 'yourcompany.onmicrosoft.com']"; string msgraphurl = "https://graph.microsoft.com"; // Always this string userid = "[Global Admin User ID, like 'admin@yourdomain.com']"; var adalAuthenticationProvider = new AdalDaemonAuthenticationProvider(clientid, appKey, tenant); var discoveryServiceHelper = new DiscoveryServiceHelper(clientid, returnurl); this.oneDriveClient = new OneDriveClient(msgraphurl+"/v1.0/users/"+ userid, adalAuthenticationProvider); authTask = adalAuthenticationProvider.AuthenticateUserAsync(msgraphurl);