Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
qimingyuan committed Jan 12, 2016
1 parent d7ad00b commit ffbf4cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dropbox.Api/Dropbox.Api.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>2.1.1</version>
<version>2.2.1</version>
<title>Dropbox v2 API Beta</title>
<authors>Dropbox Inc</authors>
<owners>Dropbox Inc</owners>
Expand All @@ -12,7 +12,7 @@
<iconUrl>https://cf.dropboxstatic.com/static/images/icons/blue_dropbox_glyph.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Portable class library for accessing the Dropbox v2 API</description>
<releaseNotes>Preview Release. Minor bug fixes.</releaseNotes>
<releaseNotes>Preview Release. Bug fixes.</releaseNotes>
<copyright>Copyright (c) Dropbox Inc. 2015</copyright>
<tags>Dropbox Api</tags>
</metadata>
Expand Down
27 changes: 27 additions & 0 deletions Dropbox.Api/DropboxOauth2Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Dropbox.Api
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -378,6 +379,11 @@ public static async Task<OAuth2Response> ProcessCodeFlowAsync(string code, strin
var raw = await response.Content.ReadAsStringAsync();
var json = JObject.Parse(raw);

if (response.StatusCode != HttpStatusCode.OK)
{
throw new OAuth2Exception(json["error"].ToString(), json.Value<string>("error_description"));
}

return new OAuth2Response(
json["access_token"].ToString(),
json["uid"].ToString(),
Expand Down Expand Up @@ -528,4 +534,25 @@ internal OAuth2Response(string accessToken, string uid, string state, string tok
/// </value>
public string TokenType { get; private set; }
}

/// <summary>
/// Exception when error occurs during oauth2 flow.
/// </summary>
public sealed class OAuth2Exception : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="OAuth2Exception"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="errorDescription">The error description</param>
public OAuth2Exception(string message, string errorDescription = null) : base(message)
{
this.ErrorDescription = errorDescription;
}

/// <summary>
/// Gets the error description.
/// </summary>
public string ErrorDescription { get; private set; }
}
}

0 comments on commit ffbf4cc

Please sign in to comment.