403错误:disallowed_useragent

我是移动应用程序开发新手,我正在开发一个iOS应用程序。 我正在使用谷歌驱动器从谷歌帐户获取文档文件到我的应用程序。我做了这个任务,工作得很好。但现在它不工作,现在当我尝试validation它显示403错误:disallowed_useragent在我的应用程序。 我GOOGLE了一下,但一些令人困惑,我读了这个堆栈溢出的问题 ,我发现谷歌驱动器已经更新,现在我不知道我是否想要重做我的任务,或不得不更新任务,只有login才能完成它,善意的任何人build议我关于这一点

非常感谢

之后的谷歌驱动器API快速启动,在AppDelegate.m didFinishLaunchingWithOptions中添加这3行代码如下所示..那么它工作正常…

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSString *userAgent = @"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/603.1.23 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602"; // set default user agent NSDictionary *dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:userAgent,@"UserAgent", nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:(dictionary)]; return YES; } 

Google OAuth政策最近的变化之后,针对这个问题有一个解决方法。

在集成Google Sign和启用Google Drive API之后,我可以使用Google Drive API来获取所有的驱动器数据。 我们只需要设置GTLServiceDrive的授权者,它是在Googlelogin后获得的。

service.authorizer = user.authentication.fetcherAuthorizer()

以下是Google GIDSignIn的代码片段,然后是抓取日历活动。

  import GoogleAPIClient import GTMOAuth2 import UIKit import GoogleSignIn class ViewController: UIViewController, GIDSignInUIDelegate, GIDSignInDelegate { private let kApiKey = "AIzaXXXXXXXXXXXXXXXXXXXXXXX" // If modifying these scopes, delete your previously saved credentials by // resetting the iOS simulator or uninstall the app. private let scopes = [kGTLAuthScopeDriveMetadataReadonly] private let service = GTLServiceDrive() override func viewDidLoad() { super.viewDidLoad() service.apiKey = kApiKey GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().scopes = scopes GIDSignIn.sharedInstance().signIn() GIDSignIn.sharedInstance().delegate = self } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { if user != nil { print("\(user)") service.authorizer = user.authentication.fetcherAuthorizer() loadDriveFiles() } } // Construct a query and get a list of upcoming events from the user calendar func loadDriveFiles() { //Googly Drive fetch Query } } 

谷歌正在改变其Oauth政策,目的是没有本地networking视图启动Oauthstream程,我也与iOS应用程序一起工作,并有同样的问题,您应该等待他们更新SDK和文档或find交替authentication使用用户信息的方式。

另一种方法是使用可以使用外部浏览器进行validation的第三方CloudRail SDK。 这篇博客文章涵盖了你所提到的问题。