cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access the missing_scope Error Messages that gets returned

How to access the missing_scope Error Messages that gets returned

App4G
Helpful | Level 6
Go to solution

There are 2 issues I would like to get some clarity on.

Environment: Xcode 12 / IOS 14.4 / SwiftyDropbox

I want to download a file from a shared scoped dropbox Folder. Previously I did not enable the files.content.read scope and thus I am getting the below error.

 

Printing description of error:

▿ [request-id 672ec403478646ebbc3bb15bea5a631f] API auth error - {

    ".tag" = "missing_scope";

    "required_scope" = "files.content.read";

}

 

This error comes via a simple print(error)

               

 

   _ = client.files.download(path: dbFile.pathLower!, destination: destination)
                    .response { response, error in
                      if let (_, url) = response {
                        /// Downloaded a copy of Remote file. Append into LocalFile list
                        print("DOWNLOADED       DropBox File:\(url.lastPathComponent)")
                        localFileList.append(dbFileNameRev)
                      } else if let callError = error {
                        print("\n\n::::::\n\(#function):: ERROR downloading file from Dropbox: \(error)")
                      }
                    }

 

 

Problem #1:

I would like to be able to get to the "missing_scope" error message and despite trying out the few examples I found on SO and in SwiftyDropbox documentation, I'm still unclear on how to get access the the nested cases/switch statement. (the swiftydropbox documentation provides example of /delete) and this https://riptutorial.com/dropbox-api/example/1351/downloading-a-file-with-every-error-case-handled-us... wasn't quite helpful 

 

I tried playing around and doing some trial and error to no avail.

 

Problem #2

I have no enabled the file.content.read scoped access in app console as well as within the code during the authorisation request, but this would only take into effect for NEW authorisations and not existing ones. (hence the error shown above). The documentation says to re-authorise the user again. However, I'm having issue whereby the authorisation call needs a ViewController reference. Is there method I can call the authorisation from a function instead? 

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

1: Here's an example of how you can drill down into this kind of error:

switch callError as CallError {
case .authError(let authError, let userMessage, let errorSummary, let requestId):
    switch authError {
    case .missingScope(let tokenScopeError):
        print("Missing scope error: \(tokenScopeError)")
        print("The required scope is: \(tokenScopeError.requiredScope)")
    default:
        print("other AuthError omitted for brevity of example")
    }
default:
    print("other CallError omitted for brevity of example")
}

2: No, there's just the authorization flow as documented here.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

1: Here's an example of how you can drill down into this kind of error:

switch callError as CallError {
case .authError(let authError, let userMessage, let errorSummary, let requestId):
    switch authError {
    case .missingScope(let tokenScopeError):
        print("Missing scope error: \(tokenScopeError)")
        print("The required scope is: \(tokenScopeError.requiredScope)")
    default:
        print("other AuthError omitted for brevity of example")
    }
default:
    print("other CallError omitted for brevity of example")
}

2: No, there's just the authorization flow as documented here.

App4G
Helpful | Level 6
Go to solution

@Greg-DB Thanks very much. with item #1 guidance provided by you, I can then enable an alert to be shown to the user and ask them to re-authenticate again using the existing Auth flow. 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    App4G Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?