I want to connect to the Google Drive API in my application in order to display a list of user files and be able to download them to the device. I am following this sample Integrate Google Drive to iOS app
I connected Google SDK and successfully authorize the user. However I can't get the list of its files in any way. I keep getting the following error:
"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
I checked my app and settings in the Google Console many times, did everything step by step, but still couldn't solve this problem. Has anyone experienced the same problem?
My code and screenshots:
//class AppDelegate...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "Me client ID"
return true
}
//class myVC: GIDSignInDelegate...
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().presentingViewController = self
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().scopes = [kGTLRAuthScopeDrive]
GIDSignIn.sharedInstance().restorePreviousSignIn()
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if let error = error {
print("Google autorization error: \(error.localizedDescription)")
return
}
guard let token = user.authentication.accessToken else { return }
SourceAuthorizationStateManager.shared.addAuthorizedSource(.googleDrive)
let fullName = user.profile.name
print("Google authorization successful. User name: \(fullName ?? "Error: no user name")\nUser token: \(token)")
}
//class GoogleDriveFileListSource...
private var fileListTicket: GTLRServiceTicket?
var files: [FileModelProtocol] {
guard let files = fileList?.files else { return [] }
return files.map { GoogleDriveFileModel($0) }
}
lazy var driveService: GTLRDriveService = {
let service = GTLRDriveService()
service.shouldFetchNextPages = true
service.isRetryEnabled = true
return service
}()
func fetchFileList(path: String?, _ completion: @escaping () -> Void) {
let query = GTLRDriveQuery_FilesList.query()
query.fields = "kind,nextPageToken,files(mimeType,id,kind,name,webViewLink,thumbnailLink,trashed)"
fileListTicket = driveService.executeQuery(query,
completionHandler: { [weak self] (_, resultObject, error) in
if let error = error {
debugPrint("driveService.executeQuery error: \(error.localizedDescription)")
return
}
guard let self = self,
let fileList = resultObject as? GTLRDrive_FileList else { return }
self.fileList = fileList
self.fileListTicket = nil
completion()
})
}


