Giter Club home page Giter Club logo

dropboxrestapi's Introduction

dropboxrestapi's People

Contributors

adrianpell avatar b0r1k avatar corywestropp avatar hurricanepkt avatar richorama avatar saguiitay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropboxrestapi's Issues

Does not have Save_URL Yet

Reference : https://www.dropbox.com/developers/core/docs#save-url

save_url
Description
Save a file from the specified URL into Dropbox. If the given path already exists, the file will be renamed to avoid the conflict (e.g. myfile (1).txt).

I am willing to do a pull request and impliment it myself however there is some design concern about how to handle the return result of the save_url. It returns a save_url_job which gives the status of the server actions.

System.AggregateException {"No auth method found"}

I'm currently adding dropbox file sharing to an application I'm working on, and I have it setup to get the auth key from the user, and then it stores the auth key in the user registry. Now I'm having issues when trying to get user profile data.

It keeps throwing "System.AggregateException" with the inner Exception of {"No auth method found"} on the line:
"var accountInfo = await client.Core.Accounts.AccountInfoAsync();"
This is the relevant piece of code:

        public static void init()
        {
            if (!RegistryManager.HasKey("DropboxAuth"))
                new DropboxAuth(); //DropboxAuth is a winform with a web brower element that the user uses to login and get their auth token
            else
            {
                authKey = RegistryManager.GetKey("DropboxAuth");
                InitClient().Wait();
            }
        }

        private static async Task InitClient()
        {
            client = new Client(DropboxAuth.options);
            var authRequestUrl = await client.Core.OAuth2.AuthorizeAsync("code");

                var token = await client.Core.OAuth2.TokenAsync(authKey);

            // Get account info -- error on this line
            var accountInfo = await client.Core.Accounts.AccountInfoAsync();

            Console.WriteLine("Uid: " + accountInfo.uid);
            Console.WriteLine("Display_name: " + accountInfo.display_name);
            Console.WriteLine("Email: " + accountInfo.email);
            initialized = true;
        }

I know that the user's auth token is being returned correctly, so I'm not sure where the auth error is coming from.

Automatic handling of HTTP error 429 Too Many Requests

Dropbox may rate-limit API requests in certain conditions by responding with HTTP 429 (I believe OAuth 1.0 apps would get HTTP 503 in the same case).

It would be nice if the library would have an opt-in parameter to automatically backoff in such cases.

Here is an example response:

HTTP/1.1 429 Too Many Requests
Server: nginx
Date: Mon, 06 Apr 2015 15:16:56 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Retry-After: 60.0

{"error": "Rate limiting oauth_accesses_per_access_token"}

As you can see, the response header includes "Retry-After" header, which indicates when it would be safe to repeat the request.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37

Core.Metadata.ThumbnailsAsync returns closed stream?

Here is a small test, which fails with an exception indicating that the stream returned by ThumbnailAsync method is closed:

using System;
using System.Configuration;
using System.Threading.Tasks;
using DropboxRestAPI;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DropBoxIndexingService.Tests
{
    [TestClass]
    public class DropBoxRestAPITests
    {
        [TestMethod]
        public async Task GetImageThumbnail()
        {
            var options = new Options
            {
                // put your token for a sandbox-ed app here, if this one expires
                AccessToken = "your access token",
            };

            var dropBoxClient = new Client(options);

            using (var thumbStream = await dropBoxClient.Core.Metadata.ThumbnailsAsync("test image path"))
            {

                var testbuf = new byte[100];
                var bytesRead = thumbStream.Read(testbuf, 0, 1);

                Assert.AreEqual(1, bytesRead);
            }
        }
    }
}

Here is the output:
Test method DropBoxIndexingService.Tests.DropBoxRestAPITests.GetImageThumbnail threw exception:
System.ObjectDisposedException: Can not access a closed Stream.
at System.Net.GZipWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Http.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at DropBoxIndexingService.Tests.DropBoxRestAPITests.d__1.MoveNext() in DropBoxRestAPITests.cs: line 30
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

Any clues?
Thanks

Delta entries fail to parse

Hi, thanks for this, I really like the API.

I'm using the longpoll_delta + delta combination, and hitting a JSON parsing error. The Delta response model assumes that the entries is of type [string]; in fact (this might be new, looking at other implementations), it's a 2-element array of [string, metadata].

I have a patch I can try and clean up if you'd like, or you might have your own preferred way of handling it.

Path with "&" and "+"

Hi , thank you again for great API.

  1. if i have path with "&", it fails, if i encoded create and encoded Version...
  2. path with "+" gets converted to " ".

It seems its a problem with HttpValueCollection with URI.EscapeDataString...

Borik

Failed to get metadata and membership details of folder shared with group

Hi there,
In my Dropbox account, I have one folder which is shared with few users and with one group. When I try to get sharing information for this folder, I am getting Json exception for below method call,
_Client.Core.Metadata.MetadataAsync(path: path, include_membership:true);

After doing some dry running code, I figured out that the Group sharing is not handled. Currently the JsonConvert.DeserializeObject(content); failed to parse the content if folder is shared with group.

I did the following changes to temporarily fix this issue:

  1. // dropboxrestapi\models\core\sharedfolder.cs
    Change
    public string[] groups {get;set;}
    to
    public Groups[] groups { get; set; }
  2. Added new class file as //dropboxrestapi\models\core\Groups.cs
namespace DropboxRestAPI.Models.Core
{
    public class Groups
    {
        public string access_type { get; set; }
        public Group group { get; set; }
    }
    public class Group
    {
        public string display_name { get; set; }
        public string id { get; set; }
        public int member_count { get; set; }
        public bool is_team_group { get; set; }
        public string access_type { get; set; }
        public bool same_team { get; set; }
    }
}

After this change, I am able to fetch the sharing information properly.

Thanks,

The request was aborted: Could not create SSL/TLS secure channel.

I started to get these recently ... i think shortly after updating to latest version ...

What is strange that this is not a consistent behavior, it happens only about 1/3 of the time...

Any inside would be appreciated ...

[WebException: The request was aborted: Could not create SSL/TLS secure channel.]
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +8286956
System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) +98

[HttpRequestException: An error occurred while sending the request.]
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
DropboxRestAPI.Utils.d__0.MoveNext() +1152
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
DropboxRestAPI.d__c`1.MoveNext() +805
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
DropboxRestAPI.Services.Core.d__1e.MoveNext() +916

include_membership flag on metadata call

Hello, first off this is a great looking API. You've done a great job.

I am having an issue though when passing in the include_membership call when trying to get the membership on a fondler and if never returns any members array. Also the Share_folder attribute does not return either on the metadata call.

is there something i'm calling incorrect?
thanks,
Rob

authorize code

hi,
i used:
var authRequestUrl = client.Core.OAuth2.Authorize("code");

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authRequestUrl);
        request.ContentType = "text/json";
        request.Method = "GET";
        request.AllowAutoRedirect = true;
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

but the request not return code

any Help?

How to authorize in DropBox?

Hello, in documentation OAuth Request Url obtained in this way:
var authRequestUrl = await client.Core.OAuth2.AuthorizeAsync("code");

But in the latest version has changed and I can not use this code. I use this:
var authRequestUrl = client.Core.OAuth2.Authorize("code");

But this code shows the error:
unknown field "code"

RedirectUri looks:
RedirectUri = "https://www.dropbox.com/1/oauth2/authorize?client_id=stgpc2qpkvcnlmj&response_type=code"

What am I doing wrong?

Dead Locks, wehn calling from asp.net website.

It seems to help when i add
ConfigureAwait(false)
return await client.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead)
to class HttpClientExtensions

Just wanted to point it out, could be issue on my site as well...

Thank you, so far really like the api

Boris

Serialization issue?

Hello,

I get the exception below. The only related cause I can think of is that I'm trying to use a more recent version of the Newtonsoft.Json library.

System.AggregateException : One or more errors occurred.
  ----> Newtonsoft.Json.JsonSerializationException : Error converting value "pending" to type 'DropboxRestAPI.Models.Core.PhotoInfo'. Path 'photo_info', line 1, position 212.
  ----> System.ArgumentException : Could not cast or convert from System.String to DropboxRestAPI.Models.Core.PhotoInfo.

Cannot force reapproval when requesting an OAuth2 Redirect URI

When I try to generate a redirect URI as part of the OAuth2 flow, and request reapproval (to force Dropbox to prompt for credentials), I get an error returned on the resulting page:

"force_reapprove": expecting either "true" or "false", got "True"

It seems that when the OAuthRequestGenerator generates parameters for the URL it uses the standard (.Net) string representation of true ... which is "True". Apparently, Dropbox doesn't like that.

Happy to generate a PR for that ...

previews API call requires root path to be "auto"

I'm attempting to get the preview for a file by using the PreviewsAsync method. After calling this method I get the error message "Root must be "auto", got "sandbox"". It looks like dropbox requires that you set the root to "auto" when doing the preview call.

error: DropboxRestAPI.Models.Exceptions.ServiceErrorException: v1_retired

hi,
this is my code:
`var options = new Options
{
ClientId = appKey, //App key
ClientSecret = appSecret, //App secret
RedirectUri = callbackUrl
};

        // Initialize a new Client (without an AccessToken)
        var client = new Client(options);
        var token = await client.Core.OAuth2.TokenAsync(code);

        var rootFolder = await client.Core.Metadata.MetadataAsync("/", list: false);`

the token is ok, but if call client.Core.Metadata.MetadataAsync the web show this error:

DropboxRestAPI.Models.Exceptions.ServiceErrorException: v1_retired

any help?

br
Max

Unhandled exception in RequestExecuter.CheckForError

Here is an unhandled exception I got in one of my tests with the latest from NuGet:

System.FormatException: Input string was not in a correct format.
    at System.Number.StringToNumber(String str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at DropboxRestAPI.RequestExecuter.<CheckForError>d__1b.MoveNext() in d:\Code\GitHub\DropboxRestAPI\src\DropboxRestAPI\RequestExecuter.cs: line 106
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DropboxRestAPI.RequestExecuter.<Execute>d__6.MoveNext() in d:\Code\GitHub\DropboxRestAPI\src\DropboxRestAPI\RequestExecuter.cs: line 66
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DropboxRestAPI.Services.Core.Metadata.<ThumbnailsAsync>d__5b.MoveNext() in d:\Code\GitHub\DropboxRestAPI\src\DropboxRestAPI\Services\Core\Metadata.cs: line 166
--- End of stack trace from previous location where exception was thrown ---

ERROR in client.Core.OAuth2.AuthorizeAsync("code");

Does someone know how to solve it?

Severity Code Description Project File Line Suppression State
Error CS1061 'IOAuth2' does not contain a definition for 'AuthorizeAsync' and no accessible extension method 'AuthorizeAsync' accepting a first argument of type 'IOAuth2' could be found (are you missing a using directive or an assembly reference?) Sample C:\Users\User\Desktop\DropboxRestAPI-master\src\Sample\Program.cs 29 Active

---According DropBox Support-------
Greg K.
Dropboxer
‎07-28-2017 01:14 PM
I'm glad to hear you sorted that out already.

For reference though, it looks like you're using a third party SDK. As it's made by a third party, we wouldn't be able to provide support for it.

Also, it unfortunately looks like that SDK uses the old Dropbox API v1, which is deprecated, and going to be retired soon.

You should move to API v2 instead. We have an official API v2 .NET SDK you can use.

Metadata Method: Files(string path,stream filestream)

I have been trying to call this method - Files(path, filestream). Following the example from the documentation. Everything else works, file upload, create folder, delete file, delete folder, even getting the list of files and folder in the dropbox account.

However this specific call, following the exact example throws this error:
"object reference not set to an instance of an object"

When I debug inside the restapi code. I realize the Stream has an Error Exception Message:
"timeouts are not supported on this stream"

in this specific line of code it fails in the Metadata : IMetadata class.

 public  MetaData Files(string path, Stream targetStream, string rev = null, string asTeamMember =     null, CancellationToken cancellationToken = default(CancellationToken))
    {
        MetaData fileMetadata = null;
        using (var restResponse =  _requestExecuter.Execute(() => _requestGenerator.Files(_options.Root, path, rev, asTeamMember), cancellationToken: cancellationToken))
        {  ...

HttpClient.SendAsync not utilising HttpCompletionOption.ResponseHeadersRead

When downloading large files this line of code in RequestJsonString method of DropboxClient class

var response = await this.httpClient.SendAsync(request);

create buffer equal to the content length of the file being uploaded. And consumer of this method will be forced to wait before all content is downloaded. Which in my case is really bad, because of stream decryption on the client.

So the proposed solution will be to add additional parameter to the SendAsync call like this:

var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

This will allow to start content processing immediately after headers parsing and will preserve RAM on the consumer side.

AggregateException with LongPollDeltaAsync

I notice that if the timeout is greater than 60-70 with the LongPollDeltaAsync, it will return an AggregateException where it mentions that a TaskCanceledException has occurred.

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.