0

Hi I'm trying to se what files I have stored on my google drive. The sign in process works without problems, but as soon as I try to request the list of files on my google drive I get this error:

Error Domain=com.google.GTLRErrorObjectDomain Code=403 "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."

I follow google drives documentation for installing it, but no matter what I do I get that error over and over again.

Here is what my viewDidLoad looks like:

var error: NSError?
GGLContext.sharedInstance().configureWithError(&error)

if error != nil {
    print(error!)
    return
}

GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().scopes = scopes

let googleSignIn = GIDSignInButton(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
googleSignIn.center = view.center

view.addSubview(googleSignIn)

This is the function for when the user succesfully signed in:

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
    if error != nil {
        print(error)
        return
    }

    print("\n")
    print(user.profile.email)
    print("\n")

    let query = GTLRDriveQuery_FilesList.query()
    query.pageSize = 10
    service.executeQuery(query, delegate: self, didFinish: #selector(displayResultWithTicket(ticket:finishedWithObject:error:))
    )

}

I does print out my email correctly, so I know it is logged in, and right after if prints my email the error appears.

This is the displayResultWithTicket function:

@objc func displayResultWithTicket(ticket: GTLRServiceTicket,
                             finishedWithObject result : GTLRDrive_FileList,
                             error : NSError?) {

    if let error = error {
        print(error)
        return
    }

    if let files = result.files, !files.isEmpty {
        print("Files:\n")
        for file in files {
            print(file.name!)
            print(file.identifier!)
        }
    } else {
        print("No files found")
    }
}

Any help is appreciated!

Benja0906
  • 1,437
  • 2
  • 15
  • 25

1 Answers1

0

To explain about your error, this documentation state that you have reached Google Drive APIs max request rate. Each limits varies on the kind of request you use. It was suggested to Batch the request.

Also, make sure that the status of Google+ API was turned ON. Wait for a few minutes after turning ON ensure to get a fresh token before trying again.

For reference on this error, you can check out this SO post.

MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65