Access restricted google docs via matlab
Mostrar comentarios más antiguos
I'm looking for some help on oauth2 authorisation using websave (or alternative) to access google docs via matlab.
If a google doc file does not have any acess restrictions, interaction is straight-forward, e.g. to save locally as a txt file:
docid = '16QTaks53H7FMBuT-zNlrj-V06aDX-K_hDCIlxBnLcos'; % example id, not a real google doc
websave([pwd '\output.txt'],['https://docs.google.com/document/d/',docid,'/export?format=txt']); %
Unfortunately if the file is access restricted, things seem to become more complex. The simple username/password approach of weboptions does not work.
I had hoped that I would be able to work it out based on the RunOnce function in the matlab2sheets FeX submission. Although this funciton runs smoothly, I have not worked out how to use the access tokens it generates to read restricted google docs (or sheets for that matter), but figured it would look something like:
load('google_tokens.mat') % google_tokens.mat is output from RunOnce and contains aSheets
headerFields = {'Authorization', ['Bearer: ', aSheets]};
options = weboptions('HeaderFields', headerFields);
docid = '16QTaks53H7FMBuT-zNlrj-V06aDX-K_hDCIlxBnLcos';
websave([pwd '\output.txt'],['https://docs.google.com/document/d/',docid,'/export?format=txt'],options); %
Does anyone know if acessing google docs in this way is possible, or any different solutions? I'm out of my comfort zone here, so any help is very much appreciated, thanks!
1 comentario
Doug Weir
el 18 de Mayo de 2022
Respuestas (0)
Categorías
Más información sobre Web Services en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!