我正在使用谷歌驱动器API。当我尝试使用
从驱动器中获取文件时return sequelize.transaction({
isolationLevel: Sequelize.Transaction.SERIALIZABLE
}, function (t) {
// your transactions
}).then(function(result) {
// transaction has been committed. Do something after the commit if required.
}).catch(function(err) {
// do something with the err.
});
我收到错误
"操作无法“完成。(许可不足)。
任何人都知道我需要在仪表板中设置哪个权限?
答案 0 :(得分:0)
如果用户需要访问非公开文件,请务必使用Google登录。或者您对用户相关文件列表感兴趣。
要执行此操作,请先请求登录。确保同时设置Google登录的UIDelegate,以便在正确的时间点显示登录屏幕:GIDSignInUIDelegate
。要展示它,您可以致电:
GIDSignIn.sharedInstance().signIn()
如果用户已经登录,您可以致电:
if userSignedInBefore {
GIDSignIn.sharedInstance().signInSilently()
}
假设您在这样的特定类中调用了您的请求(用于说明这个想法):
class Requester {
static let service = GTLServiceDrive()
static func fetchData() {
let query = GTLQueryDrive.queryForFilesList()
query?.pageSize = 1
query?.fields = “files”
service.executeQuery(query!, delegate: self, didFinish: #selector(self.displayResult(ticket:finishedWithObject:error:)))
}
...
}
此外,您需要GIDSignInDelegate
的代表,当用户登录时,这个代表会注意并存储用户的相关信息:
// https://developers.google.com/identity/sign-in/ios/
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
// Perform any operations when the user disconnects from app here.
// ...
if (error == nil) {
// Perform any operations on signed in user here.
// let userId = user.userID // For client-side use only!
// let idToken = user.authentication.idToken // Safe to send to the server
// ....
// Here you will receive an authorizer instance that implements the GTMFetcherAuthorizationProtocol protocol.
// This authorizer instance will be required by your GTLRDriveService services as authorizer reference.
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_authentication
var authorizer = user.authentication.fetcherAuthorizer()
// Here you can trigger any callback to now fetch the desired data
Requester.service.authorizer = authorizer
Requester.fetchData()
} else {
print("\(error.localizedDescription)")
}
}
有关更多信息或示例实施,请查看Google的文档: https://developers.google.com/drive/v3/web/quickstart/ios