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
Post a Comment