diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..3e2fc66051 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2015-2017 Dropbox Inc., http://www.dropbox.com/ + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/buildall.ps1 b/buildall.ps1 index f3c54b3bb4..0f29a6e74e 100644 --- a/buildall.ps1 +++ b/buildall.ps1 @@ -19,66 +19,13 @@ $nugetPath = "$nugetDir\nuget.exe" $nugetSpecPath = "$sourceDir\Dropbox.Api.nuspec" $docBuildPath = Resolve-Path "doc\StoneDocs.shfbproj" $majorVersion = "5.0" -$releaseVersion = "5.0.0" +$releaseVersion = "5.1.0" $assemblyInfoPath = "$sourceDir\AppProperties\AssemblyInfo.cs" $signKeyPath = "$sourceDir\dropbox_api_key.snk" $releaseNotes = @' Change Notes: -- Move officially supported versions to Net45 and NetStandard2.0 -- Migrate from VS2015 to VS2017 build system -- Move all build targets into single CSProj file - -- Add support for PKCE oauth flow -- Add PKCE Oauth Example -- Add System.Security.Cryptography as dependency - -(49cee186b12822462483dbca08dfb1335f55efbf) -Files Namespace - - Add internal_error to SearchError union. - - Add locked to LookupError union. - - Add cant_move_into_vault to RelocationError union. - - Add MoveIntoVaultError union. - - Add SearchMatchFieldOptions struct. - - Add optional match_field_options to SearchV2Arg struct. - - Doc/example changes. - -Sharing Namespace - - Add is_vault to SharePathError union. - - Add invalid_shared_folder to AddFolderMemberError union. - -Team Namespace - - Make members field of LegalHoldsPolicyUpdateArg struct optional. - - Add app_folder_removal_not_supported to RevokeLinkedAppError union. - - Doc/example changes. - -Team Log Namespace - - Add auto_approve to InviteMethod union. - - Add moved_from_another_team to InviteMethod union. - - Add moved_from_another_team to MemberStatus union. - - Add no_one to SharedLinkVisibility union. - - Add optional new_team to MemberChangeStatusDetails struct. - - Add optional previous_team to MemberChangeStatusDetails struct. - - Add external_sharing_create_report_details to EventDetails union. - - Add external_sharing_report_failed to EventDetails union. - - Add content_administration_policy_changed_details to EventDetails -union. - - Add external_sharing_create_report to EventType union. - - Add external_sharing_report_failed to EventType union. - - Add content_administration_policy_changed to EventType union. - - Add send_for_signature_policy_changed_details to EventDetails union. - - Add external_sharing_create_report to EventTypeArgs union. - - Add external_sharing_report_failed to EventTypeArgs union. - - Add content_administration_policy_changed to EventTypeArgs union. - - Add send_for_signature_policy_changed to EventTypeArgs union. - - Add SendForSignaturePolicy union. - - Add ExternalSharingCreateReportDetails struct. - - Add ExternalSharingReportFailedDetails struct. - - Add ContentAdministrationPolicyChangedDetails struct. - - Add SendForSignaturePolicyChangedDetails struct. - - Add ExternalSharingCreateReportType struct. - - Add ExternalSharingReportFailedType struct. - - Add ContentAdministrationPolicyChangedType struct. - - Add SendForSignaturePolicyChangedType struct. +- Fix bug to add support for short-lived tokens to team client +- Fix typo in DropboxRequestHandler '@ $builds = @( diff --git a/dropbox-sdk-dotnet/Dropbox.Api/AppProperties/AssemblyInfo.cs b/dropbox-sdk-dotnet/Dropbox.Api/AppProperties/AssemblyInfo.cs index 750d3aa029..ab17fa5429 100644 --- a/dropbox-sdk-dotnet/Dropbox.Api/AppProperties/AssemblyInfo.cs +++ b/dropbox-sdk-dotnet/Dropbox.Api/AppProperties/AssemblyInfo.cs @@ -18,7 +18,7 @@ [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("5.0.0")] -[assembly: AssemblyFileVersion("5.0.7528")] +[assembly: AssemblyFileVersion("5.0.7558")] #if DEBUG [assembly: InternalsVisibleTo("Dropbox.Api.Tests")] diff --git a/dropbox-sdk-dotnet/Dropbox.Api/Dropbox.Api.nuspec b/dropbox-sdk-dotnet/Dropbox.Api/Dropbox.Api.nuspec index 2f81fc4ef3..7d06f759bb 100644 --- a/dropbox-sdk-dotnet/Dropbox.Api/Dropbox.Api.nuspec +++ b/dropbox-sdk-dotnet/Dropbox.Api/Dropbox.Api.nuspec @@ -2,72 +2,19 @@ Dropbox.Api - 5.0.0 + 5.1.0 Dropbox v2 API Dropbox Inc Dropbox Inc - https://github.com/dropbox/dropbox-sdk-dotnet/blob/master/LICENSE + MIT https://www.dropbox.com/developers - https://cf.dropboxstatic.com/static/images/icons/blue_dropbox_glyph.png + images\icon.png false Portable class library for accessing the Dropbox v2 API Change Notes: -- Move officially supported versions to Net45 and NetStandard2.0 -- Migrate from VS2015 to VS2017 build system -- Move all build targets into single CSProj file - -- Add support for PKCE oauth flow -- Add PKCE Oauth Example -- Add System.Security.Cryptography as dependency - -(49cee186b12822462483dbca08dfb1335f55efbf) -Files Namespace - - Add internal_error to SearchError union. - - Add locked to LookupError union. - - Add cant_move_into_vault to RelocationError union. - - Add MoveIntoVaultError union. - - Add SearchMatchFieldOptions struct. - - Add optional match_field_options to SearchV2Arg struct. - - Doc/example changes. - -Sharing Namespace - - Add is_vault to SharePathError union. - - Add invalid_shared_folder to AddFolderMemberError union. - -Team Namespace - - Make members field of LegalHoldsPolicyUpdateArg struct optional. - - Add app_folder_removal_not_supported to RevokeLinkedAppError union. - - Doc/example changes. - -Team Log Namespace - - Add auto_approve to InviteMethod union. - - Add moved_from_another_team to InviteMethod union. - - Add moved_from_another_team to MemberStatus union. - - Add no_one to SharedLinkVisibility union. - - Add optional new_team to MemberChangeStatusDetails struct. - - Add optional previous_team to MemberChangeStatusDetails struct. - - Add external_sharing_create_report_details to EventDetails union. - - Add external_sharing_report_failed to EventDetails union. - - Add content_administration_policy_changed_details to EventDetails -union. - - Add external_sharing_create_report to EventType union. - - Add external_sharing_report_failed to EventType union. - - Add content_administration_policy_changed to EventType union. - - Add send_for_signature_policy_changed_details to EventDetails union. - - Add external_sharing_create_report to EventTypeArgs union. - - Add external_sharing_report_failed to EventTypeArgs union. - - Add content_administration_policy_changed to EventTypeArgs union. - - Add send_for_signature_policy_changed to EventTypeArgs union. - - Add SendForSignaturePolicy union. - - Add ExternalSharingCreateReportDetails struct. - - Add ExternalSharingReportFailedDetails struct. - - Add ContentAdministrationPolicyChangedDetails struct. - - Add SendForSignaturePolicyChangedDetails struct. - - Add ExternalSharingCreateReportType struct. - - Add ExternalSharingReportFailedType struct. - - Add ContentAdministrationPolicyChangedType struct. - - Add SendForSignaturePolicyChangedType struct. +- Fix bug to add support for short-lived tokens to team client +- Fix typo in DropboxRequestHandler Copyright (c) Dropbox Inc. 2016 Dropbox Api @@ -81,6 +28,7 @@ union. + diff --git a/dropbox-sdk-dotnet/Dropbox.Api/DropboxTeamClient.cs b/dropbox-sdk-dotnet/Dropbox.Api/DropboxTeamClient.cs index d08e1c394b..c06b891a76 100644 --- a/dropbox-sdk-dotnet/Dropbox.Api/DropboxTeamClient.cs +++ b/dropbox-sdk-dotnet/Dropbox.Api/DropboxTeamClient.cs @@ -7,6 +7,7 @@ namespace Dropbox.Api { using System; + using System.Threading.Tasks; /// /// The client which contains endpoints which perform team-level actions. @@ -18,12 +19,71 @@ public sealed partial class DropboxTeamClient : DropboxClientBase /// private readonly DropboxRequestHandlerOptions options; + /// + /// The request handler. + /// + private readonly DropboxRequestHandler requestHandler; + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + public DropboxTeamClient(string oauth2Token) + : this(oauth2Token, null, null, null, new DropboxClientConfig()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The app key to be used for refreshing tokens + public DropboxTeamClient(string oauth2RefreshToken, string appKey) + : this(null, oauth2RefreshToken, appKey, null, new DropboxClientConfig()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The app key to be used for refreshing tokens + /// The . + public DropboxTeamClient(string oauth2RefreshToken, string appKey, DropboxClientConfig config) + : this(null, oauth2RefreshToken, appKey, null, config) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 refresh token for refreshing access tokens + /// The app key to be used for refreshing tokens + /// The app secret to be used for refreshing tokens + /// The . + public DropboxTeamClient(string oauth2RefreshToken, string appKey, string appSecret, DropboxClientConfig config) + : this(null, oauth2RefreshToken, appKey, appSecret, config) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 refresh token for refreshing access tokens + /// The app key to be used for refreshing tokens + /// The app secret to be used for refreshing tokens + public DropboxTeamClient(string oauth2RefreshToken, string appKey, string appSecret) + : this(null, oauth2RefreshToken, appKey, appSecret, new DropboxClientConfig()) + { + } + /// /// Initializes a new instance of the class. /// /// The oauth2 access token for making client requests. - public DropboxTeamClient(string oauth2AccessToken) - : this(oauth2AccessToken, new DropboxClientConfig()) + /// The . + public DropboxTeamClient(string oauth2AccessToken, DropboxClientConfig config) + : this(oauth2AccessToken, null, null, null, config) { } @@ -31,10 +91,9 @@ public DropboxTeamClient(string oauth2AccessToken) /// Initializes a new instance of the class. /// /// The oauth2 access token for making client requests. - /// The user agent to use when making requests. - [Obsolete("This constructor is deprecated, please use DropboxClientConfig instead.")] - public DropboxTeamClient(string oauth2AccessToken, string userAgent) - : this(oauth2AccessToken, new DropboxClientConfig(userAgent)) + /// The time when the current access token expires, can be null if using long-lived tokens + public DropboxTeamClient(string oauth2AccessToken, DateTime oauth2AccessTokenExpiresAt) + : this(oauth2AccessToken, null, oauth2AccessTokenExpiresAt, null, null, new DropboxClientConfig()) { } @@ -42,13 +101,89 @@ public DropboxTeamClient(string oauth2AccessToken, string userAgent) /// Initializes a new instance of the class. /// /// The oauth2 access token for making client requests. + /// The time when the current access token expires, can be null if using long-lived tokens /// The . - public DropboxTeamClient(string oauth2AccessToken, DropboxClientConfig config) - : this(new DropboxRequestHandlerOptions(config, oauth2AccessToken, null, null, null, null)) + public DropboxTeamClient(string oauth2AccessToken, DateTime oauth2AccessTokenExpiresAt, DropboxClientConfig config) + : this(oauth2AccessToken, null, oauth2AccessTokenExpiresAt, null, null, config) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The oauth2 refresh token for refreshing access tokens + /// The time when the current access token expires, can be null if using long-lived tokens + /// The app key to be used for refreshing tokens + /// The app secret to be used for refreshing tokens + public DropboxTeamClient(string oauth2AccessToken, string oauth2RefreshToken, DateTime oauth2AccessTokenExpiresAt, string appKey, string appSecret) + : this(oauth2AccessToken, oauth2RefreshToken, oauth2AccessTokenExpiresAt, appKey, appSecret, new DropboxClientConfig()) + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The oauth2 refresh token for refreshing access tokens + /// The time when the current access token expires, can be null if using long-lived tokens + /// The app key to be used for refreshing tokens + /// The . + public DropboxTeamClient(string oauth2AccessToken, string oauth2RefreshToken, DateTime oauth2AccessTokenExpiresAt, string appKey, DropboxClientConfig config) + : this(new DropboxRequestHandlerOptions(config, oauth2AccessToken, oauth2RefreshToken, oauth2AccessTokenExpiresAt, appKey, null)) + { + if (oauth2AccessToken == null && oauth2RefreshToken == null) + { + throw new ArgumentException("Cannot pass in both null access and refresh token"); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The oauth2 refresh token for refreshing access tokens + /// The time when the current access token expires, can be null if using long-lived tokens + /// The app key to be used for refreshing tokens + public DropboxTeamClient(string oauth2AccessToken, string oauth2RefreshToken, DateTime oauth2AccessTokenExpiresAt, string appKey) + : this(oauth2AccessToken, oauth2RefreshToken, oauth2AccessTokenExpiresAt, appKey, null, new DropboxClientConfig()) + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The oauth2 refresh token for refreshing access tokens + /// The time when the current access token expires, can be null if using long-lived tokens + /// The app key to be used for refreshing tokens + /// The app secret to be used for refreshing tokens + /// The . + public DropboxTeamClient(string oauth2AccessToken, string oauth2RefreshToken, DateTime oauth2AccessTokenExpiresAt, string appKey, string appSecret, DropboxClientConfig config) + : this(new DropboxRequestHandlerOptions(config, oauth2AccessToken, oauth2RefreshToken, oauth2AccessTokenExpiresAt, appKey, appSecret)) + { + if (oauth2AccessToken == null && oauth2RefreshToken == null) + { + throw new ArgumentException("Cannot pass in both null access and refresh token"); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The oauth2 access token for making client requests. + /// The oauth2 refresh token for refreshing access tokens + /// The app key to be used for refreshing tokens + /// The app secret to be used for refreshing tokens + /// The . + public DropboxTeamClient(string oauth2AccessToken, string oauth2RefreshToken, string appKey, string appSecret, DropboxClientConfig config) + : this(new DropboxRequestHandlerOptions(config, oauth2AccessToken, oauth2RefreshToken, null, appKey, appSecret)) { - if (oauth2AccessToken == null) + if (oauth2AccessToken == null && oauth2RefreshToken == null) { - throw new ArgumentNullException("oauth2AccessToken"); + throw new ArgumentException("Cannot pass in both null access and refresh token"); } } @@ -56,10 +191,29 @@ public DropboxTeamClient(string oauth2AccessToken, DropboxClientConfig config) /// Initializes a new instance of the class. /// /// The request handler options. - private DropboxTeamClient(DropboxRequestHandlerOptions options) - : base(new DropboxRequestHandler(options)) + private DropboxTeamClient(DropboxRequestHandlerOptions options) : this(options, new DropboxRequestHandler(options)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The request handler options. + /// The request handler. + private DropboxTeamClient(DropboxRequestHandlerOptions options, DropboxRequestHandler requestHandler) : base(requestHandler) { this.options = options; + this.requestHandler = requestHandler; + } + + /// + /// Refreshes access token regardless of if existing token is expired + /// + /// subset of scopes to refresh token with, or null to refresh with all scopes + /// true if token is successfully refreshed, false otherwise + public Task RefreshAccessToken(string[] scopeList) + { + return this.requestHandler.RefreshAccessToken(scopeList); } /// diff --git a/dropbox-sdk-dotnet/Dropbox.Api/Stone/ITransport.cs b/dropbox-sdk-dotnet/Dropbox.Api/Stone/ITransport.cs index fd02f50981..9c735ca59d 100644 --- a/dropbox-sdk-dotnet/Dropbox.Api/Stone/ITransport.cs +++ b/dropbox-sdk-dotnet/Dropbox.Api/Stone/ITransport.cs @@ -61,7 +61,7 @@ internal interface ITransport : IDisposable /// The route name. /// The auth type of the route. /// The request encoder. - /// The response decoder. + /// The response decoder. /// The error decoder. /// An asynchronous task for the response. Task SendRpcRequestAsync( @@ -70,7 +70,7 @@ Task SendRpcRequestAsync( string route, string auth, IEncoder requestEncoder, - IDecoder resposneDecoder, + IDecoder responseDecoder, IDecoder errorDecoder); /// @@ -85,7 +85,7 @@ Task SendRpcRequestAsync( /// The route name. /// The auth type of the route. /// The request encoder. - /// The response decoder. + /// The response decoder. /// The error decoder. /// An asynchronous task for the response. Task SendUploadRequestAsync( @@ -95,7 +95,7 @@ Task SendUploadRequestAsync( string route, string auth, IEncoder requestEncoder, - IDecoder resposneDecoder, + IDecoder responseDecoder, IDecoder errorDecoder); /// @@ -109,7 +109,7 @@ Task SendUploadRequestAsync( /// The route name. /// The auth type of the route. /// The request encoder. - /// The response decoder. + /// The response decoder. /// The error decoder. /// An asynchronous task for the response. Task> SendDownloadRequestAsync( @@ -118,7 +118,7 @@ Task> SendDownloadRequestAsync requestEncoder, - IDecoder resposneDecoder, + IDecoder responseDecoder, IDecoder errorDecoder); } } diff --git a/dropbox-sdk-dotnet/LICENSE b/dropbox-sdk-dotnet/LICENSE deleted file mode 100644 index 342845a13d..0000000000 --- a/dropbox-sdk-dotnet/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2015 Dropbox Inc., http://www.dropbox.com/ - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000..da2348872a Binary files /dev/null and b/icon.png differ