Method: DropboxClient#initialize
- Defined in:
- lib/dropbox_sdk.rb
#initialize(oauth2_access_token, root = "auto", locale = nil) ⇒ DropboxClient
Args:
-
oauth2_access_token: Obtained via DropboxOAuth2Flow or DropboxOAuth2FlowNoRedirect. -
locale: The user’s current locale (used to localize error messages).
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
# File 'lib/dropbox_sdk.rb', line 722 def initialize(oauth2_access_token, root="auto", locale=nil) if oauth2_access_token.is_a?(String) @session = DropboxOAuth2Session.new(oauth2_access_token, locale) elsif oauth2_access_token.is_a?(DropboxSession) @session = oauth2_access_token @session.get_access_token if not locale.nil? @session.locale = locale end else raise ArgumentError.new("oauth2_access_token doesn't have a valid type") end @root = root.to_s # If they passed in a symbol, make it a string if not ["dropbox","app_folder","auto"].include?(@root) raise ArgumentError.new("root must be :dropbox, :app_folder, or :auto") end if @root == "app_folder" #App Folder is the name of the access type, but for historical reasons #sandbox is the URL root component that indicates this @root = "sandbox" end end |