How to get Google Bookmarks using GoogleAuthUtil.getToken()?

I’m creating an app that manages Google Bookmarks (from https://www.google.com/bookmarks/) but I’m confused on how to do both the Google authentication part and bookmark request part.

As I understand it there is no Google Bookmarks API, and bookmarks are not covered by the GoogleApiClient. I’ve tried some code from here https://developers.google.com/android/guides/http-auth where I do the following:

    try {
         String token = GoogleAuthUtil.getToken(mActivity, mEmail, mScope);
         return token;
    } catch (UserRecoverableAuthException userRecoverableException) {
         ....
         mActivity.handleException(userRecoverableException);
    } catch (GoogleAuthException fatalException) {
         ....
    }

This seems to work fine and returns an OAuth token, but then how do I use this token to get the bookmarks using my code below.

String url = "https://www.google.com/bookmarks/?output=rss";
HttpClient httpclient = new DefaultHttpClient();
HttpGet get = queryBookmarks(url, outputType, numBookmarks, sortOrder, null);
try {
    HttpResponse response = httpclient.execute(get);
    BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    line = in.readLine();
    ....

Should I even be using GoogleAuthUtil.getToken() or do I need to use the GoogleApiClient. Any help much appreciated !


Source: bookmarks

Leave a Reply