MCPcopy Create free account
hub / github.com/dropbox/dbxcli / initDbx

Function initDbx

cmd/root.go:206–254  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

204}
205
206func initDbx(cmd *cobra.Command, args []string) (err error) {
207 currentAuthContext = nil
208
209 if err := initCommandContext(cmd); err != nil {
210 return err
211 }
212
213 if commandIsJSONHelp(cmd) {
214 return nil
215 }
216 if err := validateOutputFormat(cmd); err != nil {
217 return err
218 }
219
220 if commandSkipsAuth(cmd) {
221 return nil
222 }
223
224 verbose, _ := cmd.Flags().GetBool("verbose")
225 asMember, _ := cmd.Flags().GetString("as-member")
226 domain, _ := cmd.Flags().GetString("domain")
227
228 if accessToken := os.Getenv(envAccessToken); accessToken != "" {
229 config = makeDropboxConfig(accessToken, verbose, asMember, domain)
230 currentAuthContext = &authContext{
231 Source: authSourceEnv,
232 Refreshable: false,
233 AuthFile: authFileNone,
234 }
235 config = withRootNamespace(config, tokenType(cmd))
236 return nil
237 }
238
239 tokType := tokenType(cmd)
240 credential, _, err := getAccessCredential(tokType, domain, false)
241 if err != nil {
242 return err
243 }
244
245 config = makeDropboxConfig(credential.AccessToken, verbose, asMember, domain)
246 currentAuthContext = &authContext{
247 Source: authSourceSaved,
248 Refreshable: credential.RefreshToken != "",
249 AuthFile: authFileKind(),
250 }
251 config = withRootNamespace(config, tokType)
252
253 return
254}
255
256func withRootNamespace(cfg dropbox.Config, tokType string) dropbox.Config {
257 // Team manage tokens are for administrative operations and don't need a path root.

Calls 9

initCommandContextFunction · 0.85
commandIsJSONHelpFunction · 0.85
validateOutputFormatFunction · 0.85
commandSkipsAuthFunction · 0.85
makeDropboxConfigFunction · 0.85
withRootNamespaceFunction · 0.85
tokenTypeFunction · 0.85
getAccessCredentialFunction · 0.85
authFileKindFunction · 0.85