Skip to content

Commit ffbf4cc

Browse files
committed
Bug fixes.
1 parent d7ad00b commit ffbf4cc

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Dropbox.Api/Dropbox.Api.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>$id$</id>
5-
<version>2.1.1</version>
5+
<version>2.2.1</version>
66
<title>Dropbox v2 API Beta</title>
77
<authors>Dropbox Inc</authors>
88
<owners>Dropbox Inc</owners>
@@ -12,7 +12,7 @@
1212
<iconUrl>https://cf.dropboxstatic.com/static/images/icons/blue_dropbox_glyph.png</iconUrl>
1313
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1414
<description>Portable class library for accessing the Dropbox v2 API</description>
15-
<releaseNotes>Preview Release. Minor bug fixes.</releaseNotes>
15+
<releaseNotes>Preview Release. Bug fixes.</releaseNotes>
1616
<copyright>Copyright (c) Dropbox Inc. 2015</copyright>
1717
<tags>Dropbox Api</tags>
1818
</metadata>

Dropbox.Api/DropboxOauth2Helper.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Dropbox.Api
88
{
99
using System;
1010
using System.Collections.Generic;
11+
using System.Net;
1112
using System.Net.Http;
1213
using System.Text;
1314
using System.Threading.Tasks;
@@ -378,6 +379,11 @@ public static async Task<OAuth2Response> ProcessCodeFlowAsync(string code, strin
378379
var raw = await response.Content.ReadAsStringAsync();
379380
var json = JObject.Parse(raw);
380381

382+
if (response.StatusCode != HttpStatusCode.OK)
383+
{
384+
throw new OAuth2Exception(json["error"].ToString(), json.Value<string>("error_description"));
385+
}
386+
381387
return new OAuth2Response(
382388
json["access_token"].ToString(),
383389
json["uid"].ToString(),
@@ -528,4 +534,25 @@ internal OAuth2Response(string accessToken, string uid, string state, string tok
528534
/// </value>
529535
public string TokenType { get; private set; }
530536
}
537+
538+
/// <summary>
539+
/// Exception when error occurs during oauth2 flow.
540+
/// </summary>
541+
public sealed class OAuth2Exception : Exception
542+
{
543+
/// <summary>
544+
/// Initializes a new instance of the <see cref="OAuth2Exception"/> class.
545+
/// </summary>
546+
/// <param name="message">The message.</param>
547+
/// <param name="errorDescription">The error description</param>
548+
public OAuth2Exception(string message, string errorDescription = null) : base(message)
549+
{
550+
this.ErrorDescription = errorDescription;
551+
}
552+
553+
/// <summary>
554+
/// Gets the error description.
555+
/// </summary>
556+
public string ErrorDescription { get; private set; }
557+
}
531558
}

0 commit comments

Comments
 (0)