1

OAuth2 を使用して Google ドライブからダウンロードしようとしていますが、URL を認証できません。

次のエラーが表示されます。

2013-08-21 21:22:39.569 LoudCloud[4790:c07] 承認に成功しました... 2013-08-21 21:22:40.262 LoudCloud[4790:c07] エラー: エラー Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 401" UserInfo=0x98b90f0 {AFNetworkingOperationFailingURLRequestErrorKey=https://doc-0k-bg-docs.googleusercontent.com/docs/securesc/6gj8c1544p7s7pniqjbc4mq6j0fb056i/8bj1nr5shkpsku5m0mde1rr8v7n975ll/1377108000000/00742820994415136760/00742820994415136760/0B0kZ8xc_ZGhbWnZOQUVuTGtObjA?h =16653014193614665626&e=download&gd=true>, NSErrorFailingURLKey= https://doc-0k-bg-docs.googleusercontent.com/docs/securesc/6gj8c1544p7s7pniqjbc4mq6j0fb056i/8bj1nr5shkpsku5m0mde1rr8v7n975ll/1377108000000/00742820994415136760/00742820994415136760/0B0kZ8xc_ZGhbWnZOQUVuTGtObjA?h=16653014193614665626&e=download&gd=真、NSLocalizedDescription = (200-299) の予期されるステータス コード、401 を取得、AFNetworkingOperationFailingURLResponseErrorKey =}

コード:

GTMOAuth2Authentication *auth =
        [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
                                                              clientID:kClientID
                                                          clientSecret:kClientSecret];

        NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];

        [auth authorizeRequest:req completionHandler:^(NSError *error) {
            if (error == nil) {
                NSLog(@"Authorization successful...");
            }
            else {
                NSLog(@"Authorization failed...");
            }
        }];

        AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:req];

        op.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];

        [op setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
            float percentage = ((float)((int)totalBytesRead) / (float)((int)totalBytesExpectedToRead)) * 100.0;

            NSLog(@"Download percentage: %f", percentage);
        }];

        [op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
            NSLog(@"Successfully downloaded file to %@", path);
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            NSLog(@"Error: %@", error);
        }];

        [op start];
4

0 に答える 0