###前提・実現したいこと
Objective-Cで、GoogleDriveへファイルをアップロードする処理を書きました。
環境:
XCode8.3
Deployment Target 9.0
Base SDK 10.3
podの設定
platform :ios, '9.0'
pod 'GoogleAPIClientForREST/Drive', '> 1.2.1'> 3.0.3'
pod 'Google/SignIn', '
Googleへのログインは成功したのですが、GoogleDriveへのファイルアップロード処理で、Domain=com.google.HTTPStatus Code=401 "(null)" 、エラーが発生しました。
###発生している問題・エラーメッセージ
Error Domain=com.google.HTTPStatus Code=401 "(null)" UserInfo={data=<7b226572 726f7222 3a7b2265 72726f72 73223a5b 7b22646f 6d61696e 223a2267 6c6f6261 6c222c22 72656173 6f6e223a 22726571 75697265 64222c22 6d657373 61676522 3a224c6f 67696e20 52657175 69726564 222c226c 6f636174 696f6e54 79706522 3a226865 61646572 222c226c 6f636174 696f6e22 3a224175 74686f72 697a6174 696f6e22 7d5d2c22 636f6465 223a3430 312c226d 65737361 6765223a 224c6f67 696e2052 65717569 72656422 7d7d>}
###該当のソースコード
Objective
1.h 2#import <UIKit/UIKit.h> 3#import "GTLRDrive.h" 4#import <Google/SignIn.h> 5 6@interface BackupViewController2 : UIViewController <GIDSignInDelegate, GIDSignInUIDelegate> 7@property (nonatomic, strong) GTLRDriveService *service; 8@end 9 10 11.m 12- (void)signIn:(GIDSignIn *)signIn 13didSignInForUser:(GIDGoogleUser *)user 14 withError:(NSError *)error { 15 if (error == nil) { 16 [self showAlert:@"Error" message:@"失敗"]; 17 self.service.authorizer = nil; 18 } else { 19 self.service.authorizer = user.authentication.fetcherAuthorizer; 20 self.service.APIKey = @"AIzaSyA-lLo_iZuhoYJSkVVNIaZmBMCLkCF_30k"; 21 22 NSData * fileContent = [@"ahcnuefewfewfsnjcdsjc" dataUsingEncoding:NSUTF8StringEncoding]; 23 GTLRUploadParameters * uploadParameters = [GTLRUploadParameters uploadParametersWithData:fileContent MIMEType:@"text/plain"]; 24 GTLRDrive_File * driveFile = [GTLRDrive_File new]; 25 driveFile.name = @"First blood.txt"; 26 27 GTLRDriveQuery_FilesCreate * query = [GTLRDriveQuery_FilesCreate queryWithObject:driveFile uploadParameters:uploadParameters]; 28 query.fields = @"981300619618-5qrr859q2dm9f04nfq24cg2d6cvtb8dq.apps.googleusercontent.com"; 29 30 [self.service executeQuery:query completionHandler:^(GTLRServiceTicket * _Nonnull callbackTicket, id _Nullable object, NSError * _Nullable callbackError) { 31 32 if (!callbackError) { 33 NSLog(@"---upLoad File Success---"); 34 } 35 else{ 36 NSLog(@"---upLoad File fail---"); 37 } 38 }]; 39 } 40}
###試したこと
完全に新規プロジェクトを作って試してみたり、APIKeyを変えてみたりしましたが、GoogleDriveへのアクセスのハンドラー内で
NSLog(@"---upLoad File fail---");
に来てしまいます。
###補足情報(言語/FW/ツール等のバージョンなど)
MacOS 10.3 Sierra
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。