java - Google Drive API Authentication - how to do it and how to implement it? -
i'm trying title of document using file id. here's code:
private static void printfile(drive service, string fileid) { try { file file = service.files().get(fileid).execute(); system.out.println("title: " + file.gettitle()); } catch (ioexception e) { system.out.println("an error occured: " + e); } } }
however, when run receive 403 forbidden error states, "daily limit unauthenticated use exceeded. continued use requires signup."
i assume have authenticate, seeing i'm new google drive api , java, i'm confused how (forgive me). found webpage: https://developers.google.com/drive/web/auth/web-server explains how authenticate i'm still confused. page lists multiple classes thing such exchange authorization code access token , use oauth 2.0 credentials.
my question need use of these classes authenticate? , how implement them code?
here brief explanation @ http level.
- any google drive rest api call requires http
authorization: bearer xxxxxx
set. if there no such header, you'll 403 you're experiencing - the xxxxx access token. there myriad ways 1 of these depending on user experience want implement , whether you're trying access user's drive files or application's. read google docs , experiment oauth playground.
the google java library attempts abstract of above. whether job or not decide. i've had more success calling rest api directly.
Comments
Post a Comment