You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

App4G's avatar
App4G
Helpful | Level 6
4 years ago

How to access the missing_scope Error Messages that gets returned

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-using-the-swiftydropbox-library 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: 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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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's avatar
      App4G
      Helpful | Level 6

      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. 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 40 minutes ago
333 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!