1

I have two modules in my project. The first is responsible for creating a folder and a spreadsheet in the google drive. The second is responsible for inserting rows in the spreadsheet. For the first module I am referring to the sample here. For Second module I am referring the examples here. Is there any way I can use the authentication done in the first module using the GoogleAPIClient in the second module without trying to authenticate again. Also for information the second module runs in an AsyncTask inside a service. Any suggestion how to do this?

Community
  • 1
  • 1
Sush
  • 6,839
  • 1
  • 18
  • 26

1 Answers1

1

Finally ended up using below :

   String SCOPE = "oauth2:https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/"

   accessToken = GoogleAuthUtil.getTokenWithNotification(context,HelperUtils.getStringFromPrefs(context, AppConstants.SP_ACCOUNT_NAME,""), SCOPE,null);
        Log.d(TAG,"AccessToken : " + accessToken);
    SpreadsheetService service = new SpreadsheetService("V1");
    service.setProtocolVersion(SpreadsheetService.Versions.V3);
    service.setHeader("Authorization", "Bearer " + accessToken);

Used the account name selected from the account picker in the first module.

Sush
  • 6,839
  • 1
  • 18
  • 26
  • What does this return: HelperUtils.getStringFromPrefs(context, AppConstants.SP_ACCOUNT_NAME,"") – Dean Wild Sep 10 '15 at 09:08
  • This is a custom method I had created to get the Account name from the shared preference that I had put before. – Sush Sep 11 '15 at 09:25