Git Product home page Git Product logo

amazonclouddriveapi's Introduction

Amazon Cloud Drive Api for .NET

General implementation of REST API for Amazon Cloud Drive. Not all functions are implemented, but it can download/upload files and organize files/folders.

Build status Nuget badge

Nuget

You can find nuget package with name AmazonCloudDriveApi

Example

Desktop authentication

First you need to create security profile in Amazon Dev console and whitelist it. Since August 2016 it became complicated. There you get your app ClientId and ClientSecret.

Then you create root API object.

this.amazon = new AmazonDrive(ClientId, ClientSecret);

To authenticate new connection.

var success = await this.amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write | CloudDriveScopes.Profile, TimeSpan.FromMinutes(10));

To be able to reauthenticate without confirmation each time on Amazon web site you need to reuse Access and Refresh tokens. After some time tokens get updated by API they have to be stored somewhere by application. For that you need to assign implementation of ITokenUpdateListener which will store tokens. Reference to the implementation is weak, so do not use any local object, object with your implementation should live while API is used.

Implementation example

public abstract class AmazonTokenListener : ITokenUpdateListener
{
public void OnTokenUpdated(string access_token, string refresh_token, DateTime expires_in)
  {
      var settings = Properties.Settings.Default;

      settings.AuthToken = access_token;
      settings.AuthRenewToken = refresh_token;
      settings.AuthTokenExpiration = expires_in;
      settings.Save();
  }
}

Assign object to OnTokenUpdate property before any login attempt

this.tokenSaver = new AmazonTokenListener();
this.amazon.OnTokenUpdate

Next time when you restart your application and want to relogin into Amazon cloud Drive use

var success = amazon.AuthenticationByTokens(settings.AuthToken, settings.AuthRenewToken, settings.AuthTokenExpiration)

amazonclouddriveapi's People

Contributors

kyrodan avatar rambalac avatar saguiitay avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.