Google Drive (401) Not Authorized Error -
i have been using google drive sdk integration since october. has worked fine since then, , have not modified code in project since got working. today, unknown reason, every request download or upload file drive returns error:
the remote server returned error (401) not authorized.
the section of code working on is:
public static stream getdownloadstream(string id) { file file = driveservice.files.get(id).fetch(); if (!string.isnullorempty(file.downloadurl)) { stream stream; var request = (httpwebrequest) webrequest.create( new uri(file.downloadurl)); auth.applyauthenticationtorequest(request); try { var response = (httpwebresponse)request.getresponse(); if (response.statuscode == httpstatuscode.ok) { stream = response.getresponsestream(); } else { throw new exception(response.statusdescription); } return stream; } catch(exception e) { getcredentials(); return getdownloadstream(id); } } throw new exception("file cannot downloaded."); }
the error returned @ request.getresponse() method call. driveservice loads file, , file has appears formed downloadurl. driveservice seems work in rest of code, searches , retrieves file info properly, reason, won't download or upload. has there been change format of downloadurl @ google server end need incorporate code?
have disabled web security? seems google drive checking one.
--disable-web-security
if so, enable web security. worked me.
Comments
Post a Comment