如何设置Google Drive ReadOnly文件IOS应用程序的权限

时间:2016-04-22 00:36:23

标签: ios google-drive-api

我正在将Google Drive SDK与iOS应用集成。我想从谷歌驱动器中读取文件。没有上传或删除。如何在授权期间设置ReadOnly文件权限。这是我的代码。

dd

1 个答案:

答案 0 :(得分:0)

创建GTMOAuth2ViewControllerTouch时可以设置权限。将其设置为kGTLAuthScopeDriveReadonly。这给了只读权限。

GTMOAuth2ViewControllerTouch *authController;
    authController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDriveReadonly
                                                                clientID:kClientID
                                                            clientSecret:nil
                                                        keychainItemName:kKeychainItemName
                                                                delegate:self
                                                        finishedSelector:@selector(viewController:finishedWithAuth:error:)]; 

您可以在GTLDriveConstants.h文件中看到其他权限

// Authorization scope
// View and manage the files and documents in your Google Drive
GTL_EXTERN NSString * const kGTLAuthScopeDrive;                 // "https://www.googleapis.com/auth/drive"
// View and manage its own configuration data in your Google Drive
GTL_EXTERN NSString * const kGTLAuthScopeDriveAppdata;          // "https://www.googleapis.com/auth/drive.appdata"
// View your Google Drive apps
GTL_EXTERN NSString * const kGTLAuthScopeDriveAppsReadonly;     // "https://www.googleapis.com/auth/drive.apps.readonly"
// View and manage Google Drive files that you have opened or created with this
// app
GTL_EXTERN NSString * const kGTLAuthScopeDriveFile;             // "https://www.googleapis.com/auth/drive.file"
// View metadata for files and documents in your Google Drive
GTL_EXTERN NSString * const kGTLAuthScopeDriveMetadataReadonly;  // "https://www.googleapis.com/auth/drive.metadata.readonly"
// View the files and documents in your Google Drive
GTL_EXTERN NSString * const kGTLAuthScopeDriveReadonly;         // "https://www.googleapis.com/auth/drive.readonly"
// Modify your Google Apps Script scripts' behavior
GTL_EXTERN NSString * const kGTLAuthScopeDriveScripts;          // "https://www.googleapis.com/auth/drive.scripts"
相关问题