dropbox_api 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +20 -0
- data/TODO.md +8 -0
- data/docs/DropboxApi/Authenticator.html +8 -14
- data/docs/DropboxApi/ChunkedUploader.html +2 -2
- data/docs/DropboxApi/Client.html +344 -16
- data/docs/DropboxApi/ConnectionBuilder.html +259 -24
- data/docs/DropboxApi/Endpoints/Auth/TokenRevoke.html +5 -5
- data/docs/DropboxApi/Endpoints/Auth.html +2 -2
- data/docs/DropboxApi/Endpoints/Base.html +88 -7
- data/docs/DropboxApi/Endpoints/ContentDownload.html +22 -33
- data/docs/DropboxApi/Endpoints/ContentUpload.html +22 -33
- data/docs/DropboxApi/Endpoints/Files/Copy.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CopyBatch.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CopyBatchCheck.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CopyReferenceGet.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CopyReferenceSave.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CreateFileRequest.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CreateFolder.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CreateFolderBatch.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/CreateFolderBatchCheck.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/Delete.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/DeleteBatch.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/DeleteBatchCheck.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/Download.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/GetMetadata.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/GetPreview.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/GetTemporaryLink.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/GetThumbnail.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/GetThumbnailBatch.html +6 -6
- data/docs/DropboxApi/Endpoints/Files/ListFolder.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/ListFolderContinue.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/ListFolderGetLatestCursor.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/ListFolderLongpoll.html +6 -6
- data/docs/DropboxApi/Endpoints/Files/ListRevisions.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/Move.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/PermanentlyDelete.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/Restore.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/SaveUrl.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/SaveUrlCheckJobStatus.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/Search.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/SearchContinue.html +300 -0
- data/docs/DropboxApi/Endpoints/Files/Upload.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/UploadSessionAppendV2.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/UploadSessionFinish.html +5 -5
- data/docs/DropboxApi/Endpoints/Files/UploadSessionStart.html +5 -5
- data/docs/DropboxApi/Endpoints/Files.html +4 -4
- data/docs/DropboxApi/Endpoints/Rpc.html +23 -34
- data/docs/DropboxApi/Endpoints/RpcContent.html +21 -26
- data/docs/DropboxApi/Endpoints/RpcNotify.html +21 -26
- data/docs/DropboxApi/Endpoints/Sharing/AddFileMember.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/AddFolderMember.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/CreateSharedLinkWithSettings.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/GetSharedLinkMetadata.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/ListFileMembers.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/ListFolderMembers.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/ListSharedLinks.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/RevokeSharedLink.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/ShareFolder.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing/UnshareFile.html +5 -5
- data/docs/DropboxApi/Endpoints/Sharing.html +2 -2
- data/docs/DropboxApi/Endpoints/Users/GetAccount.html +5 -5
- data/docs/DropboxApi/Endpoints/Users/GetAccountBatch.html +5 -5
- data/docs/DropboxApi/Endpoints/Users/GetCurrentAccount.html +5 -5
- data/docs/DropboxApi/Endpoints/Users/GetSpaceUsage.html +5 -5
- data/docs/DropboxApi/Endpoints/Users.html +2 -2
- data/docs/DropboxApi/Endpoints.html +2 -2
- data/docs/DropboxApi/Errors/AddFileMemberError.html +2 -2
- data/docs/DropboxApi/Errors/AddFolderMemberError.html +2 -2
- data/docs/DropboxApi/Errors/AddMemberSelectorError.html +2 -2
- data/docs/DropboxApi/Errors/AlreadySharedError.html +2 -2
- data/docs/DropboxApi/Errors/BadPathError.html +2 -2
- data/docs/DropboxApi/Errors/BasicError.html +3 -3
- data/docs/DropboxApi/Errors/CantCopySharedFolderError.html +2 -2
- data/docs/DropboxApi/Errors/CantMoveFolderIntoItselfError.html +2 -2
- data/docs/DropboxApi/Errors/CantNestSharedFolderError.html +2 -2
- data/docs/DropboxApi/Errors/CantShareOutsideTeamError.html +2 -2
- data/docs/DropboxApi/Errors/ContainsSharedFolderError.html +2 -2
- data/docs/DropboxApi/Errors/ConversionError.html +2 -2
- data/docs/DropboxApi/Errors/CreateFileRequestError.html +2 -2
- data/docs/DropboxApi/Errors/CreateFolderBatchError.html +2 -2
- data/docs/DropboxApi/Errors/CreateFolderError.html +2 -2
- data/docs/DropboxApi/Errors/CreateSharedLinkWithSettingsError.html +2 -2
- data/docs/DropboxApi/Errors/CursorClosedError.html +2 -2
- data/docs/DropboxApi/Errors/CursorNotClosedError.html +2 -2
- data/docs/DropboxApi/Errors/DeleteError.html +2 -2
- data/docs/DropboxApi/Errors/DisallowedNameError.html +2 -2
- data/docs/DropboxApi/Errors/DisallowedSharedLinkPolicyError.html +2 -2
- data/docs/DropboxApi/Errors/DownloadError.html +2 -2
- data/docs/DropboxApi/Errors/DownloadFailedError.html +2 -2
- data/docs/DropboxApi/Errors/EmailUnverifiedError.html +2 -2
- data/docs/DropboxApi/Errors/ExpiredAccessTokenError.html +143 -0
- data/docs/DropboxApi/Errors/FileAncestorConflictError.html +2 -2
- data/docs/DropboxApi/Errors/FileConflictError.html +2 -2
- data/docs/DropboxApi/Errors/FileMemberActionError.html +2 -2
- data/docs/DropboxApi/Errors/FolderConflictError.html +2 -2
- data/docs/DropboxApi/Errors/GetAccountError.html +2 -2
- data/docs/DropboxApi/Errors/GetCopyReferenceError.html +2 -2
- data/docs/DropboxApi/Errors/GetMetadataError.html +2 -2
- data/docs/DropboxApi/Errors/GroupDeletedError.html +2 -2
- data/docs/DropboxApi/Errors/GroupNotOnTeamError.html +2 -2
- data/docs/DropboxApi/Errors/HttpError.html +2 -2
- data/docs/DropboxApi/Errors/InProgressError.html +2 -2
- data/docs/DropboxApi/Errors/InsideAppFolderError.html +2 -2
- data/docs/DropboxApi/Errors/InsideOsxPackageError.html +2 -2
- data/docs/DropboxApi/Errors/InsidePublicFolderError.html +2 -2
- data/docs/DropboxApi/Errors/InsideSharedFolderError.html +2 -2
- data/docs/DropboxApi/Errors/InsufficientPlanError.html +2 -2
- data/docs/DropboxApi/Errors/InsufficientSpaceError.html +2 -2
- data/docs/DropboxApi/Errors/InternalError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidCommentError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidCopyReferenceError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidCursorError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidDropboxIdError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidEmailError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidFileError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidIdError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidMemberError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidPathError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidRevisionError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidSettingsError.html +2 -2
- data/docs/DropboxApi/Errors/InvalidUrlError.html +2 -2
- data/docs/DropboxApi/Errors/IsAppFolderError.html +2 -2
- data/docs/DropboxApi/Errors/IsFileError.html +2 -2
- data/docs/DropboxApi/Errors/IsFolderError.html +2 -2
- data/docs/DropboxApi/Errors/IsOsxPackageError.html +2 -2
- data/docs/DropboxApi/Errors/IsPublicFolderError.html +2 -2
- data/docs/DropboxApi/Errors/ListFolderContinueError.html +2 -2
- data/docs/DropboxApi/Errors/ListFolderError.html +2 -2
- data/docs/DropboxApi/Errors/ListFolderLongpollError.html +2 -2
- data/docs/DropboxApi/Errors/ListRevisionsError.html +2 -2
- data/docs/DropboxApi/Errors/ListSharedLinksError.html +2 -2
- data/docs/DropboxApi/Errors/LookupError.html +2 -2
- data/docs/DropboxApi/Errors/MalformedPathError.html +2 -2
- data/docs/DropboxApi/Errors/NoAccountError.html +2 -2
- data/docs/DropboxApi/Errors/NoPermissionError.html +2 -2
- data/docs/DropboxApi/Errors/NoWritePermissionError.html +2 -2
- data/docs/DropboxApi/Errors/NotAMemberError.html +2 -2
- data/docs/DropboxApi/Errors/NotFileError.html +2 -2
- data/docs/DropboxApi/Errors/NotFolderError.html +2 -2
- data/docs/DropboxApi/Errors/NotFoundError.html +2 -2
- data/docs/DropboxApi/Errors/PollError.html +2 -2
- data/docs/DropboxApi/Errors/PreviewError.html +2 -2
- data/docs/DropboxApi/Errors/RateLimitError.html +2 -2
- data/docs/DropboxApi/Errors/RelocationBatchEntryError.html +2 -2
- data/docs/DropboxApi/Errors/RelocationError.html +2 -2
- data/docs/DropboxApi/Errors/RestoreError.html +2 -2
- data/docs/DropboxApi/Errors/RestrictedContentError.html +2 -2
- data/docs/DropboxApi/Errors/RevokeSharedLinkError.html +2 -2
- data/docs/DropboxApi/Errors/SaveCopyReferenceError.html +2 -2
- data/docs/DropboxApi/Errors/SaveUrlError.html +2 -2
- data/docs/DropboxApi/Errors/SearchError.html +2 -2
- data/docs/DropboxApi/Errors/SettingsError.html +2 -2
- data/docs/DropboxApi/Errors/ShareFolderError.html +2 -2
- data/docs/DropboxApi/Errors/SharePathError.html +2 -2
- data/docs/DropboxApi/Errors/SharedFolderAccessError.html +2 -2
- data/docs/DropboxApi/Errors/SharedLinkAccessDeniedError.html +2 -2
- data/docs/DropboxApi/Errors/SharedLinkAlreadyExistsError.html +2 -2
- data/docs/DropboxApi/Errors/SharedLinkError.html +2 -2
- data/docs/DropboxApi/Errors/SharedLinkMalformedError.html +2 -2
- data/docs/DropboxApi/Errors/SharedLinkNotFoundError.html +2 -2
- data/docs/DropboxApi/Errors/SharingFileAccessError.html +2 -2
- data/docs/DropboxApi/Errors/SharingUserError.html +2 -2
- data/docs/DropboxApi/Errors/TeamFolderError.html +2 -2
- data/docs/DropboxApi/Errors/TeamPolicyDisallowsMemberPolicyError.html +2 -2
- data/docs/DropboxApi/Errors/ThumbnailBatchError.html +2 -2
- data/docs/DropboxApi/Errors/ThumbnailError.html +2 -2
- data/docs/DropboxApi/Errors/TooManyFilesError.html +2 -2
- data/docs/DropboxApi/Errors/TooManyMembersError.html +2 -2
- data/docs/DropboxApi/Errors/TooManyPendingInvitesError.html +2 -2
- data/docs/DropboxApi/Errors/TooManyRequestsError.html +2 -2
- data/docs/DropboxApi/Errors/TooManySharedFolderTargetsError.html +2 -2
- data/docs/DropboxApi/Errors/TooManyWriteOperationsError.html +2 -2
- data/docs/DropboxApi/Errors/UnmountedError.html +2 -2
- data/docs/DropboxApi/Errors/UnshareFileError.html +2 -2
- data/docs/DropboxApi/Errors/UnsupportedContentError.html +2 -2
- data/docs/DropboxApi/Errors/UnsupportedExtensionError.html +2 -2
- data/docs/DropboxApi/Errors/UnsupportedImageError.html +2 -2
- data/docs/DropboxApi/Errors/UnsupportedLinkTypeError.html +2 -2
- data/docs/DropboxApi/Errors/UnverifiedDropboxId.html +2 -2
- data/docs/DropboxApi/Errors/UploadError.html +2 -2
- data/docs/DropboxApi/Errors/UploadSessionFinishError.html +2 -2
- data/docs/DropboxApi/Errors/UploadSessionLookupError.html +2 -2
- data/docs/DropboxApi/Errors/UploadSessionOffsetError.html +2 -2
- data/docs/DropboxApi/Errors/UploadWriteFailedError.html +2 -2
- data/docs/DropboxApi/Errors/WriteConflictError.html +2 -2
- data/docs/DropboxApi/Errors/WriteError.html +2 -2
- data/docs/DropboxApi/Errors.html +4 -4
- data/docs/DropboxApi/Metadata/AccessLevel.html +2 -2
- data/docs/DropboxApi/Metadata/AddFileMemberResult.html +2 -2
- data/docs/DropboxApi/Metadata/AddMember.html +2 -2
- data/docs/DropboxApi/Metadata/Base.html +3 -3
- data/docs/DropboxApi/Metadata/BasicAccount.html +8 -3
- data/docs/DropboxApi/Metadata/CommitInfo.html +2 -2
- data/docs/DropboxApi/Metadata/Deleted.html +2 -2
- data/docs/DropboxApi/Metadata/Dimensions.html +2 -2
- data/docs/DropboxApi/Metadata/Field.html +2 -2
- data/docs/DropboxApi/Metadata/File.html +2 -2
- data/docs/DropboxApi/Metadata/FileCategoriesList.html +2 -2
- data/docs/DropboxApi/Metadata/FileCategory.html +2 -2
- data/docs/DropboxApi/Metadata/FileExtensionsList.html +2 -2
- data/docs/DropboxApi/Metadata/FileLinkMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/FileMemberAction.html +2 -2
- data/docs/DropboxApi/Metadata/FileRequest.html +2 -2
- data/docs/DropboxApi/Metadata/FileStatus.html +2 -2
- data/docs/DropboxApi/Metadata/Folder.html +2 -2
- data/docs/DropboxApi/Metadata/FolderLinkMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/FolderSharingInfo.html +2 -2
- data/docs/DropboxApi/Metadata/LinkPermissions.html +2 -2
- data/docs/DropboxApi/Metadata/Location.html +2 -2
- data/docs/DropboxApi/Metadata/MediaInfo.html +2 -2
- data/docs/DropboxApi/Metadata/MediaMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/Member.html +2 -2
- data/docs/DropboxApi/Metadata/MemberAction.html +2 -2
- data/docs/DropboxApi/Metadata/MemberActionList.html +2 -2
- data/docs/DropboxApi/Metadata/MemberPermission.html +2 -2
- data/docs/DropboxApi/Metadata/MemberPermissionList.html +2 -2
- data/docs/DropboxApi/Metadata/MetadataV2.html +2 -2
- data/docs/DropboxApi/Metadata/Name.html +2 -2
- data/docs/DropboxApi/Metadata/NamespaceId.html +210 -0
- data/docs/DropboxApi/Metadata/ParentFolderAccessInfo.html +2 -2
- data/docs/DropboxApi/Metadata/PhotoMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/Resource.html +2 -2
- data/docs/DropboxApi/Metadata/RootInfo.html +227 -0
- data/docs/DropboxApi/Metadata/SearchMatchFieldOptions.html +2 -2
- data/docs/DropboxApi/Metadata/SearchMatchTypeV2.html +2 -2
- data/docs/DropboxApi/Metadata/SearchMatchV2.html +2 -2
- data/docs/DropboxApi/Metadata/SearchOptions.html +2 -2
- data/docs/DropboxApi/Metadata/SearchOrderBy.html +2 -2
- data/docs/DropboxApi/Metadata/SharedFolder.html +2 -2
- data/docs/DropboxApi/Metadata/SharedFolderPolicy.html +2 -2
- data/docs/DropboxApi/Metadata/SharedLink.html +2 -2
- data/docs/DropboxApi/Metadata/SharedLinkMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/SpaceAllocation.html +2 -2
- data/docs/DropboxApi/Metadata/SpaceUsage.html +2 -2
- data/docs/DropboxApi/Metadata/Tag.html +2 -2
- data/docs/DropboxApi/Metadata/Team.html +2 -2
- data/docs/DropboxApi/Metadata/TeamMemberInfo.html +2 -2
- data/docs/DropboxApi/Metadata/TeamRootInfo.html +140 -0
- data/docs/DropboxApi/Metadata/ThumbnailBatchResultData.html +2 -2
- data/docs/DropboxApi/Metadata/ThumbnailBatchResultEntry.html +2 -2
- data/docs/DropboxApi/Metadata/UploadSessionCursor.html +2 -2
- data/docs/DropboxApi/Metadata/UserRootInfo.html +140 -0
- data/docs/DropboxApi/Metadata/VideoMetadata.html +2 -2
- data/docs/DropboxApi/Metadata/WriteMode.html +2 -2
- data/docs/DropboxApi/Metadata.html +4 -4
- data/docs/DropboxApi/MiddleWare/DecodeResult.html +2 -2
- data/docs/DropboxApi/MiddleWare/PathRoot.html +412 -0
- data/docs/DropboxApi/MiddleWare/Stack.html +2 -2
- data/docs/DropboxApi/MiddleWare.html +4 -4
- data/docs/DropboxApi/OptionsValidator.html +3 -3
- data/docs/DropboxApi/ResultBuilder.html +2 -2
- data/docs/DropboxApi/Results/AddFileMemberResultList.html +2 -2
- data/docs/DropboxApi/Results/Base.html +2 -2
- data/docs/DropboxApi/Results/BasicAccountBatch.html +2 -2
- data/docs/DropboxApi/Results/CopyBatchResult.html +2 -2
- data/docs/DropboxApi/Results/CreateFolderBatchResult.html +2 -2
- data/docs/DropboxApi/Results/CreateFolderBatchResultEntry.html +2 -2
- data/docs/DropboxApi/Results/DeleteBatchResult.html +2 -2
- data/docs/DropboxApi/Results/DeleteBatchResultEntry.html +2 -2
- data/docs/DropboxApi/Results/GetCopyReferenceResult.html +2 -2
- data/docs/DropboxApi/Results/GetTemporaryLinkResult.html +2 -2
- data/docs/DropboxApi/Results/GetThumbnailBatchResult.html +2 -2
- data/docs/DropboxApi/Results/ListFolderGetLatestCursorResult.html +2 -2
- data/docs/DropboxApi/Results/ListFolderLongpollResult.html +2 -2
- data/docs/DropboxApi/Results/ListFolderResult.html +2 -2
- data/docs/DropboxApi/Results/ListRevisionsResult.html +2 -2
- data/docs/DropboxApi/Results/ListSharedLinksResult.html +2 -2
- data/docs/DropboxApi/Results/RelocationBatchResult.html +2 -2
- data/docs/DropboxApi/Results/RelocationBatchResultEntry.html +2 -2
- data/docs/DropboxApi/Results/SaveCopyReferenceResult.html +2 -2
- data/docs/DropboxApi/Results/SaveUrlJobStatus.html +2 -2
- data/docs/DropboxApi/Results/SaveUrlResult.html +2 -2
- data/docs/DropboxApi/Results/Search/Match.html +2 -2
- data/docs/DropboxApi/Results/Search.html +2 -2
- data/docs/DropboxApi/Results/SearchV2Result.html +6 -6
- data/docs/DropboxApi/Results/ShareFolderLaunch.html +2 -2
- data/docs/DropboxApi/Results/SharedFileMembers.html +2 -2
- data/docs/DropboxApi/Results/SharedFolderMembers.html +2 -2
- data/docs/DropboxApi/Results/UploadSessionStart.html +2 -2
- data/docs/DropboxApi/Results/VoidResult.html +2 -2
- data/docs/DropboxApi/Results.html +2 -2
- data/docs/DropboxApi.html +3 -3
- data/docs/DropboxScaffoldBuilder.html +2 -2
- data/docs/_index.html +61 -12
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +110 -24
- data/docs/file.api_coverage.html +2 -2
- data/docs/file.rails_setup.html +2 -2
- data/docs/index.html +110 -24
- data/docs/method_list.html +437 -325
- data/docs/top-level-namespace.html +2 -2
- data/dropbox_api.gemspec +2 -6
- data/lib/dropbox_api/connection_builder.rb +1 -1
- data/lib/dropbox_api/endpoints/rpc_notify.rb +1 -1
- data/lib/dropbox_api/version.rb +1 -1
- metadata +15 -78
data/docs/file.README.html
CHANGED
|
@@ -116,42 +116,110 @@ have to get an authorization code.</p>
|
|
|
116
116
|
<span class='comment'>#=> #<DropboxApi::Client ...>
|
|
117
117
|
</span></code></pre>
|
|
118
118
|
|
|
119
|
-
<p>
|
|
120
|
-
|
|
119
|
+
<p>The official documentation on the process to get an authorization code is
|
|
120
|
+
<a href="https://developers.dropbox.com/es-es/oauth-guide#implementing-oauth">here</a>,
|
|
121
|
+
it describes the two options listed below.</p>
|
|
121
122
|
|
|
122
123
|
<h4 id="option-a-get-your-access-token-from-the-website">Option A: Get your access token from the website</h4>
|
|
123
124
|
|
|
124
|
-
<p>
|
|
125
|
-
|
|
126
|
-
<em>My apps</em>
|
|
127
|
-
haven't done so yet
|
|
125
|
+
<p>For a quick test, you can obtain an access token from the App Console in
|
|
126
|
+
<a href="https://www.dropbox.com/developers/">Dropbox's website</a>. Select from
|
|
127
|
+
<em>My apps</em> your application, you may need to create one if you
|
|
128
|
+
haven't done so yet. Under your application settings, find section
|
|
129
|
+
<em>OAuth 2</em>, there is a button to generate an access token.</p>
|
|
128
130
|
|
|
129
|
-
<
|
|
130
|
-
to generate an access token.</p>
|
|
131
|
+
<h4 id="option-b-oauth2-code-flow">Option B: OAuth2 Code Flow</h4>
|
|
131
132
|
|
|
132
|
-
<
|
|
133
|
+
<p>This is typically what you will use in production, you can obtain an
|
|
134
|
+
authorization code with a 3-step process:</p>
|
|
133
135
|
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span> <span class='comment'>#=> "https://www.dropbox.com/..."
|
|
136
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Get an authorization URL.
|
|
137
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
138
|
+
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span> <span class='comment'>#=> "https://www.dropbox.com/..."
|
|
138
139
|
</span>
|
|
139
|
-
<span class='comment'>#
|
|
140
|
-
</span><span class='comment'>#
|
|
140
|
+
<span class='comment'># 2. Log into Dropbox and authorize your app. You need to open the
|
|
141
|
+
</span><span class='comment'># authorization URL in your browser.
|
|
141
142
|
</span>
|
|
142
|
-
<span class='
|
|
143
|
-
</span><span class='
|
|
144
|
-
</span><span class='
|
|
145
|
-
</span
|
|
143
|
+
<span class='comment'># 3. Exchange the authorization code for a reusable access token (not visible
|
|
144
|
+
</span><span class='comment'># to the user).
|
|
145
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_get_token'>get_token</span><span class='lparen'>(</span><span class='const'>CODE</span><span class='rparen'>)</span> <span class='comment'>#=> #<OAuth2::AccessToken ...>`
|
|
146
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span><span class='period'>.</span><span class='id identifier rubyid_token'>token</span> <span class='comment'>#=> "VofXAX8D..."
|
|
147
|
+
</span>
|
|
148
|
+
<span class='comment'># Keep this token, you'll need it to initialize a `DropboxApi::Client` object:
|
|
149
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='rparen'>)</span>
|
|
146
150
|
|
|
147
|
-
<
|
|
151
|
+
<span class='comment'># For backwards compatibility, the following also works:
|
|
152
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_access_token'>access_token</span><span class='period'>.</span><span class='id identifier rubyid_token'>token</span><span class='rparen'>)</span>
|
|
153
|
+
</code></pre>
|
|
148
154
|
|
|
149
|
-
<
|
|
150
|
-
Dropbox's <a href="https://www.dropbox.com/developers/reference/oauth-guide#oauth-2-on-the-web">OAuth guide</a>.</p>
|
|
155
|
+
<h5 id="integration-with-rails">Integration with Rails</h5>
|
|
151
156
|
|
|
152
157
|
<p>If you have a Rails application, you might be interested in this <a href="http://jesus.github.io/dropbox_api/file.rails_setup.html">setup
|
|
153
158
|
guide</a>.</p>
|
|
154
159
|
|
|
160
|
+
<h5 id="using-refresh-tokens">Using refresh tokens</h5>
|
|
161
|
+
|
|
162
|
+
<p>Access tokens are short-lived by default (as of September 30th, 2021),
|
|
163
|
+
applications that require long-lived access to the API without additional
|
|
164
|
+
interaction with the user should use refresh tokens.</p>
|
|
165
|
+
|
|
166
|
+
<p>The process is similar but a token refresh might seamlessly occur as you
|
|
167
|
+
perform API calls. When this happens you'll need to store the
|
|
168
|
+
new token hash if you want to continue using this session, you can use the
|
|
169
|
+
<code>on_token_refreshed</code> callback to do this.</p>
|
|
170
|
+
|
|
171
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Get an authorization URL, requesting offline access type.
|
|
172
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
173
|
+
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span><span class='lparen'>(</span><span class='label'>token_access_type:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>offline</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
174
|
+
|
|
175
|
+
<span class='comment'># 2. Log into Dropbox and authorize your app. You need to open the
|
|
176
|
+
</span><span class='comment'># authorization URL in your browser.
|
|
177
|
+
</span>
|
|
178
|
+
<span class='comment'># 3. Exchange the authorization code for a reusable access token
|
|
179
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_get_token'>get_token</span><span class='lparen'>(</span><span class='const'>CODE</span><span class='rparen'>)</span> <span class='comment'>#=> #<OAuth2::AccessToken ...>`
|
|
180
|
+
</span>
|
|
181
|
+
<span class='comment'># You can now use the access token to initialize a DropboxApi::Client, you
|
|
182
|
+
</span><span class='comment'># should also provide a callback function to store the updated access token
|
|
183
|
+
</span><span class='comment'># whenever it's refreshed.
|
|
184
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
|
185
|
+
<span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='comma'>,</span>
|
|
186
|
+
<span class='label'>on_token_refreshed:</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='op'>|</span>
|
|
187
|
+
<span class='comment'># token_hash is a serializable Hash, something like this:
|
|
188
|
+
</span> <span class='comment'># {
|
|
189
|
+
</span> <span class='comment'># "uid"=>"440",
|
|
190
|
+
</span> <span class='comment'># "token_type"=>"bearer",
|
|
191
|
+
</span> <span class='comment'># "scope"=>"account_info.read account_info.write...",
|
|
192
|
+
</span> <span class='comment'># "account_id"=>"dbid:AABOLtA1rT6rRK4vajKZ...",
|
|
193
|
+
</span> <span class='comment'># :access_token=>"sl.A5Ez_CBsqJILhDawHlmXSoZEhLZ4nuLFVRs6AJ...",
|
|
194
|
+
</span> <span class='comment'># :refresh_token=>"iMg4Me_oKYUAAAAAAAAAAapQixCgwfXOxuubCuK_...",
|
|
195
|
+
</span> <span class='comment'># :expires_at=>1632948328
|
|
196
|
+
</span> <span class='comment'># }
|
|
197
|
+
</span> <span class='const'>SomewhereSafe</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='rparen'>)</span>
|
|
198
|
+
<span class='rbrace'>}</span>
|
|
199
|
+
<span class='rparen'>)</span>
|
|
200
|
+
</code></pre>
|
|
201
|
+
|
|
202
|
+
<p>Once you've gone through the process above, you can skip the steps that require
|
|
203
|
+
user interaction in subsequent initializations of <code>DropboxApi::Client</code>. For
|
|
204
|
+
example:</p>
|
|
205
|
+
|
|
206
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Initialize an authenticator
|
|
207
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
208
|
+
|
|
209
|
+
<span class='comment'># 2. Retrieve the token hash you previously stored somewhere safe, you can use
|
|
210
|
+
</span><span class='comment'># it to build a new access token.
|
|
211
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='const'>OAuth2</span><span class='op'>::</span><span class='const'>AccessToken</span><span class='period'>.</span><span class='id identifier rubyid_from_hash'>from_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_authenticator'>authenticator</span><span class='comma'>,</span> <span class='id identifier rubyid_token_hash'>token_hash</span><span class='rparen'>)</span>
|
|
212
|
+
|
|
213
|
+
<span class='comment'># 3. You now have an access token, so you can initialize a client like you
|
|
214
|
+
</span><span class='comment'># would normally:
|
|
215
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
|
216
|
+
<span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='comma'>,</span>
|
|
217
|
+
<span class='label'>on_token_refreshed:</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='op'>|</span>
|
|
218
|
+
<span class='const'>SomewhereSafe</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='rparen'>)</span>
|
|
219
|
+
<span class='rbrace'>}</span>
|
|
220
|
+
<span class='rparen'>)</span>
|
|
221
|
+
</code></pre>
|
|
222
|
+
|
|
155
223
|
<h3 id="performing-api-calls">Performing API calls</h3>
|
|
156
224
|
|
|
157
225
|
<p>Once you've initialized a client, for example:</p>
|
|
@@ -194,6 +262,24 @@ example:</p>
|
|
|
194
262
|
<a href="http://www.xuuso.com/dropbox_api/DropboxApi/Client.html#upload_by_chunks-instance_method">method documentation</a>
|
|
195
263
|
to find out all available options.</p>
|
|
196
264
|
|
|
265
|
+
<h3 id="accessing-team-folders">Accessing Team Folders</h3>
|
|
266
|
+
|
|
267
|
+
<p>In order to access your team scope you need to add the namespace_id to you request headers.
|
|
268
|
+
This can be done using the middlewere layer as per the below:</p>
|
|
269
|
+
|
|
270
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>VofXAX8D...</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
|
271
|
+
<span class='comment'>#=> #<DropboxApi::Client ...>
|
|
272
|
+
</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_namespace_id'>namespace_id</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_get_current_account'>get_current_account</span><span class='period'>.</span><span class='id identifier rubyid_root_info'>root_info</span><span class='period'>.</span><span class='id identifier rubyid_root_namespace_id'>root_namespace_id</span>
|
|
273
|
+
|
|
274
|
+
<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_list_folder'>list_folder</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
275
|
+
<span class='comment'>#=> Now returns the team folders
|
|
276
|
+
</span></code></pre>
|
|
277
|
+
|
|
278
|
+
<p>You could unset the namespace ID at any point afterwards with just:</p>
|
|
279
|
+
|
|
280
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_namespace_id'>namespace_id</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|
281
|
+
</code></pre>
|
|
282
|
+
|
|
197
283
|
<h2 id="dependencies">Dependencies</h2>
|
|
198
284
|
|
|
199
285
|
<p>This gem depends on
|
|
@@ -252,9 +338,9 @@ endpoints are implemented, check out the <code>lib/dropbox_api/endpoints</code>
|
|
|
252
338
|
</div></div>
|
|
253
339
|
|
|
254
340
|
<div id="footer">
|
|
255
|
-
Generated on
|
|
341
|
+
Generated on Wed Sep 29 23:44:24 2021 by
|
|
256
342
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
257
|
-
0.9.26 (ruby-2.5
|
|
343
|
+
0.9.26 (ruby-2.6.5).
|
|
258
344
|
</div>
|
|
259
345
|
|
|
260
346
|
</div>
|
data/docs/file.api_coverage.html
CHANGED
|
@@ -585,9 +585,9 @@ issue</a>.</p>
|
|
|
585
585
|
</div></div>
|
|
586
586
|
|
|
587
587
|
<div id="footer">
|
|
588
|
-
Generated on
|
|
588
|
+
Generated on Wed Sep 29 23:44:24 2021 by
|
|
589
589
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
590
|
-
0.9.26 (ruby-2.5
|
|
590
|
+
0.9.26 (ruby-2.6.5).
|
|
591
591
|
</div>
|
|
592
592
|
|
|
593
593
|
</div>
|
data/docs/file.rails_setup.html
CHANGED
|
@@ -142,9 +142,9 @@ settings.</li>
|
|
|
142
142
|
</div></div>
|
|
143
143
|
|
|
144
144
|
<div id="footer">
|
|
145
|
-
Generated on
|
|
145
|
+
Generated on Wed Sep 29 23:44:24 2021 by
|
|
146
146
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
147
|
-
0.9.26 (ruby-2.5
|
|
147
|
+
0.9.26 (ruby-2.6.5).
|
|
148
148
|
</div>
|
|
149
149
|
|
|
150
150
|
</div>
|
data/docs/index.html
CHANGED
|
@@ -116,42 +116,110 @@ have to get an authorization code.</p>
|
|
|
116
116
|
<span class='comment'>#=> #<DropboxApi::Client ...>
|
|
117
117
|
</span></code></pre>
|
|
118
118
|
|
|
119
|
-
<p>
|
|
120
|
-
|
|
119
|
+
<p>The official documentation on the process to get an authorization code is
|
|
120
|
+
<a href="https://developers.dropbox.com/es-es/oauth-guide#implementing-oauth">here</a>,
|
|
121
|
+
it describes the two options listed below.</p>
|
|
121
122
|
|
|
122
123
|
<h4 id="option-a-get-your-access-token-from-the-website">Option A: Get your access token from the website</h4>
|
|
123
124
|
|
|
124
|
-
<p>
|
|
125
|
-
|
|
126
|
-
<em>My apps</em>
|
|
127
|
-
haven't done so yet
|
|
125
|
+
<p>For a quick test, you can obtain an access token from the App Console in
|
|
126
|
+
<a href="https://www.dropbox.com/developers/">Dropbox's website</a>. Select from
|
|
127
|
+
<em>My apps</em> your application, you may need to create one if you
|
|
128
|
+
haven't done so yet. Under your application settings, find section
|
|
129
|
+
<em>OAuth 2</em>, there is a button to generate an access token.</p>
|
|
128
130
|
|
|
129
|
-
<
|
|
130
|
-
to generate an access token.</p>
|
|
131
|
+
<h4 id="option-b-oauth2-code-flow">Option B: OAuth2 Code Flow</h4>
|
|
131
132
|
|
|
132
|
-
<
|
|
133
|
+
<p>This is typically what you will use in production, you can obtain an
|
|
134
|
+
authorization code with a 3-step process:</p>
|
|
133
135
|
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span> <span class='comment'>#=> "https://www.dropbox.com/..."
|
|
136
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Get an authorization URL.
|
|
137
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
138
|
+
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span> <span class='comment'>#=> "https://www.dropbox.com/..."
|
|
138
139
|
</span>
|
|
139
|
-
<span class='comment'>#
|
|
140
|
-
</span><span class='comment'>#
|
|
140
|
+
<span class='comment'># 2. Log into Dropbox and authorize your app. You need to open the
|
|
141
|
+
</span><span class='comment'># authorization URL in your browser.
|
|
141
142
|
</span>
|
|
142
|
-
<span class='
|
|
143
|
-
</span><span class='
|
|
144
|
-
</span><span class='
|
|
145
|
-
</span
|
|
143
|
+
<span class='comment'># 3. Exchange the authorization code for a reusable access token (not visible
|
|
144
|
+
</span><span class='comment'># to the user).
|
|
145
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_get_token'>get_token</span><span class='lparen'>(</span><span class='const'>CODE</span><span class='rparen'>)</span> <span class='comment'>#=> #<OAuth2::AccessToken ...>`
|
|
146
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span><span class='period'>.</span><span class='id identifier rubyid_token'>token</span> <span class='comment'>#=> "VofXAX8D..."
|
|
147
|
+
</span>
|
|
148
|
+
<span class='comment'># Keep this token, you'll need it to initialize a `DropboxApi::Client` object:
|
|
149
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='rparen'>)</span>
|
|
146
150
|
|
|
147
|
-
<
|
|
151
|
+
<span class='comment'># For backwards compatibility, the following also works:
|
|
152
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_access_token'>access_token</span><span class='period'>.</span><span class='id identifier rubyid_token'>token</span><span class='rparen'>)</span>
|
|
153
|
+
</code></pre>
|
|
148
154
|
|
|
149
|
-
<
|
|
150
|
-
Dropbox's <a href="https://www.dropbox.com/developers/reference/oauth-guide#oauth-2-on-the-web">OAuth guide</a>.</p>
|
|
155
|
+
<h5 id="integration-with-rails">Integration with Rails</h5>
|
|
151
156
|
|
|
152
157
|
<p>If you have a Rails application, you might be interested in this <a href="http://jesus.github.io/dropbox_api/file.rails_setup.html">setup
|
|
153
158
|
guide</a>.</p>
|
|
154
159
|
|
|
160
|
+
<h5 id="using-refresh-tokens">Using refresh tokens</h5>
|
|
161
|
+
|
|
162
|
+
<p>Access tokens are short-lived by default (as of September 30th, 2021),
|
|
163
|
+
applications that require long-lived access to the API without additional
|
|
164
|
+
interaction with the user should use refresh tokens.</p>
|
|
165
|
+
|
|
166
|
+
<p>The process is similar but a token refresh might seamlessly occur as you
|
|
167
|
+
perform API calls. When this happens you'll need to store the
|
|
168
|
+
new token hash if you want to continue using this session, you can use the
|
|
169
|
+
<code>on_token_refreshed</code> callback to do this.</p>
|
|
170
|
+
|
|
171
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Get an authorization URL, requesting offline access type.
|
|
172
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
173
|
+
<span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_authorize_url'>authorize_url</span><span class='lparen'>(</span><span class='label'>token_access_type:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>offline</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
174
|
+
|
|
175
|
+
<span class='comment'># 2. Log into Dropbox and authorize your app. You need to open the
|
|
176
|
+
</span><span class='comment'># authorization URL in your browser.
|
|
177
|
+
</span>
|
|
178
|
+
<span class='comment'># 3. Exchange the authorization code for a reusable access token
|
|
179
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='id identifier rubyid_authenticator'>authenticator</span><span class='period'>.</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='period'>.</span><span class='id identifier rubyid_get_token'>get_token</span><span class='lparen'>(</span><span class='const'>CODE</span><span class='rparen'>)</span> <span class='comment'>#=> #<OAuth2::AccessToken ...>`
|
|
180
|
+
</span>
|
|
181
|
+
<span class='comment'># You can now use the access token to initialize a DropboxApi::Client, you
|
|
182
|
+
</span><span class='comment'># should also provide a callback function to store the updated access token
|
|
183
|
+
</span><span class='comment'># whenever it's refreshed.
|
|
184
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
|
185
|
+
<span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='comma'>,</span>
|
|
186
|
+
<span class='label'>on_token_refreshed:</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='op'>|</span>
|
|
187
|
+
<span class='comment'># token_hash is a serializable Hash, something like this:
|
|
188
|
+
</span> <span class='comment'># {
|
|
189
|
+
</span> <span class='comment'># "uid"=>"440",
|
|
190
|
+
</span> <span class='comment'># "token_type"=>"bearer",
|
|
191
|
+
</span> <span class='comment'># "scope"=>"account_info.read account_info.write...",
|
|
192
|
+
</span> <span class='comment'># "account_id"=>"dbid:AABOLtA1rT6rRK4vajKZ...",
|
|
193
|
+
</span> <span class='comment'># :access_token=>"sl.A5Ez_CBsqJILhDawHlmXSoZEhLZ4nuLFVRs6AJ...",
|
|
194
|
+
</span> <span class='comment'># :refresh_token=>"iMg4Me_oKYUAAAAAAAAAAapQixCgwfXOxuubCuK_...",
|
|
195
|
+
</span> <span class='comment'># :expires_at=>1632948328
|
|
196
|
+
</span> <span class='comment'># }
|
|
197
|
+
</span> <span class='const'>SomewhereSafe</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='rparen'>)</span>
|
|
198
|
+
<span class='rbrace'>}</span>
|
|
199
|
+
<span class='rparen'>)</span>
|
|
200
|
+
</code></pre>
|
|
201
|
+
|
|
202
|
+
<p>Once you've gone through the process above, you can skip the steps that require
|
|
203
|
+
user interaction in subsequent initializations of <code>DropboxApi::Client</code>. For
|
|
204
|
+
example:</p>
|
|
205
|
+
|
|
206
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># 1. Initialize an authenticator
|
|
207
|
+
</span><span class='id identifier rubyid_authenticator'>authenticator</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Authenticator.html" title="DropboxApi::Authenticator (class)">Authenticator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Authenticator.html#initialize-instance_method" title="DropboxApi::Authenticator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'>CLIENT_ID</span><span class='comma'>,</span> <span class='const'>CLIENT_SECRET</span><span class='rparen'>)</span>
|
|
208
|
+
|
|
209
|
+
<span class='comment'># 2. Retrieve the token hash you previously stored somewhere safe, you can use
|
|
210
|
+
</span><span class='comment'># it to build a new access token.
|
|
211
|
+
</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='const'>OAuth2</span><span class='op'>::</span><span class='const'>AccessToken</span><span class='period'>.</span><span class='id identifier rubyid_from_hash'>from_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_authenticator'>authenticator</span><span class='comma'>,</span> <span class='id identifier rubyid_token_hash'>token_hash</span><span class='rparen'>)</span>
|
|
212
|
+
|
|
213
|
+
<span class='comment'># 3. You now have an access token, so you can initialize a client like you
|
|
214
|
+
</span><span class='comment'># would normally:
|
|
215
|
+
</span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
|
216
|
+
<span class='label'>access_token:</span> <span class='id identifier rubyid_access_token'>access_token</span><span class='comma'>,</span>
|
|
217
|
+
<span class='label'>on_token_refreshed:</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='op'>|</span>
|
|
218
|
+
<span class='const'>SomewhereSafe</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_new_token_hash'>new_token_hash</span><span class='rparen'>)</span>
|
|
219
|
+
<span class='rbrace'>}</span>
|
|
220
|
+
<span class='rparen'>)</span>
|
|
221
|
+
</code></pre>
|
|
222
|
+
|
|
155
223
|
<h3 id="performing-api-calls">Performing API calls</h3>
|
|
156
224
|
|
|
157
225
|
<p>Once you've initialized a client, for example:</p>
|
|
@@ -194,6 +262,24 @@ example:</p>
|
|
|
194
262
|
<a href="http://www.xuuso.com/dropbox_api/DropboxApi/Client.html#upload_by_chunks-instance_method">method documentation</a>
|
|
195
263
|
to find out all available options.</p>
|
|
196
264
|
|
|
265
|
+
<h3 id="accessing-team-folders">Accessing Team Folders</h3>
|
|
266
|
+
|
|
267
|
+
<p>In order to access your team scope you need to add the namespace_id to you request headers.
|
|
268
|
+
This can be done using the middlewere layer as per the below:</p>
|
|
269
|
+
|
|
270
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DropboxApi.html" title="DropboxApi (module)">DropboxApi</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DropboxApi/Client.html" title="DropboxApi::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DropboxApi/Client.html#initialize-instance_method" title="DropboxApi::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>VofXAX8D...</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
|
271
|
+
<span class='comment'>#=> #<DropboxApi::Client ...>
|
|
272
|
+
</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_namespace_id'>namespace_id</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_get_current_account'>get_current_account</span><span class='period'>.</span><span class='id identifier rubyid_root_info'>root_info</span><span class='period'>.</span><span class='id identifier rubyid_root_namespace_id'>root_namespace_id</span>
|
|
273
|
+
|
|
274
|
+
<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_list_folder'>list_folder</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
275
|
+
<span class='comment'>#=> Now returns the team folders
|
|
276
|
+
</span></code></pre>
|
|
277
|
+
|
|
278
|
+
<p>You could unset the namespace ID at any point afterwards with just:</p>
|
|
279
|
+
|
|
280
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_namespace_id'>namespace_id</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|
281
|
+
</code></pre>
|
|
282
|
+
|
|
197
283
|
<h2 id="dependencies">Dependencies</h2>
|
|
198
284
|
|
|
199
285
|
<p>This gem depends on
|
|
@@ -252,9 +338,9 @@ endpoints are implemented, check out the <code>lib/dropbox_api/endpoints</code>
|
|
|
252
338
|
</div></div>
|
|
253
339
|
|
|
254
340
|
<div id="footer">
|
|
255
|
-
Generated on
|
|
341
|
+
Generated on Wed Sep 29 23:44:24 2021 by
|
|
256
342
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
257
|
-
0.9.26 (ruby-2.5
|
|
343
|
+
0.9.26 (ruby-2.6.5).
|
|
258
344
|
</div>
|
|
259
345
|
|
|
260
346
|
</div>
|