objective c - Uploading a file to Google drive using iOS sdk -


in current application, trying upload .text file google drive using google sdk ios. issue every time got error message in log insufficient permission, if have faced or have idea on type of error kindly me.

here code,

        gtldrivefile *file = [gtldrivefile object];         file.descriptionproperty = @"uploaded ios app.";         file.mimetype = @"text/*";         file.name=@"mytextfile";         nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"mytestfile" oftype:@"txt"];          gtluploadparameters *uploadparameters = [gtluploadparameters uploadparameterswithfileurl:[nsurl urlwithstring:filepath] mimetype:file.mimetype];           gtlquerydrive *query = [gtlquerydrive queryforfilescreatewithobject:file uploadparameters:uploadparameters];          [self.service executequery:query completionhandler:^(gtlserviceticket *ticket, id object, nserror *error) {             if (error) {                 nslog(@"error: %@", error);             }else{              }         }]; 

log print when action performed,

unexpected response data (uploading wrong url?) {"error":{"code":403,"message":"insufficient permission","data":[{"domain":"global","reason":"insufficientpermissions","message":"insufficient permission"}]},"id":"gtl_3"}

premature failure: upload-status:"final" location:(null)

i solve problem

first step

change scope [kgtlauthscopedrivefile]

but after first step, got same 403 error

because app in phone have scope [kgtlauthscopedrivemetadatareadonly]

second step

reset application or build in simulator

i think first auth key chain using scope readonly existed doesn't write file google drive

after change scope , re-auth works

if change kkeychainitemname's value re-auth again new scope

google says in quickstart tutorial

// if modifying these scopes, delete saved credentials // resetting ios simulator or uninstall app. // private let scopes = [kgtlauthscopedrivefile] 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -