Skip to content

A wrapper around microsoft identity connector and microsoft graph api to access one drive content

License

Notifications You must be signed in to change notification settings

632575987/Xamarin.OneDrive.Connector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xamarin.OneDrive.Connector

A wrapper around microsoft identity connector and microsoft graph api to access one drive content

Sample of how to use the library

Simplest get-started sample

   using Xamarin.OneDrive;

   var connector = new Connector("YOUR_MICROSOFT_APPLICATION_ID", "User.Read");
   if (await connector.ConnectAsync())
   {
      var httpMessage = await connector.GetAsync("me");
      /* json message with the requested data */
   }
   connector.Dispose();

Using the profile plugin to request user profile data

   using Xamarin.OneDrive;
   using Xamarin.OneDrive.Profile;

   var connector = new Connector("YOUR_MICROSOFT_APPLICATION_ID", "User.Read");
   if (await connector.ConnectAsync())
   {
      var profile = await connector.GetProfileAsync();
      Console.WriteLine($"Connected to {profile.Name} account through address {profile.Mail}");
   }
   connector.Dispose();

Using the files plugin to search download and manipulate files stored in OneDrive

   using Xamarin.OneDrive;
   using Xamarin.OneDrive.Files;

   var connector = new Connector("YOUR_MICROSOFT_APPLICATION_ID", "Files.Read");
   if (await connector.ConnectAsync())
   {
      var fileList = await connector.SearchFilesAsync("*.zip");
      Console.WriteLine($"Retrieved {fileList.Count} files on the search request");
      var file = fileList[0];
      Console.WriteLine($"The file {file.FileName} has {file.Bytes} bytes and is located on {file.FilePath}.");
   }
   connector.Dispose();

Install instructions

  • You can add the library to your project using the nuget package:

    dotnet add package Xamarin.OneDrive.Connector
  • And the optionals plugins:

    dotnet add package Xamarin.OneDrive.Connector.Profile  
    dotnet add package Xamarin.OneDrive.Connector.Files  
  • You will nedd a microsoft application id that you can get following this guide.

Build using

Changelog

v0.1.*

Trying to learn and apply unit tests (quantum physics for me).
Conditional framework's builds according to platform specifics, need because android requires some extras steps on acquiring token.
Extending the HttpClient library to accommodate token acquisition.
Implementing the plugin concept using profile as the first try.
Preparing projects to be build, packed and deploy by the server.
Provide a sample application. Implementing the UploadAsync method to send file content to drive. SearchFiles overloads to allow searching on specific folder.
Methods for listing folder's childs.

Authors

License

MIT License - see the LICENSE file for details.

About

A wrapper around microsoft identity connector and microsoft graph api to access one drive content

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%