Developer Console

Integrate with Google APIs

The A3L Authentication SDK supports integration with Google APIs. This integration can allow a user access to a Google service after they sign in to your app with their Google account. Currently, A3L Authentication supports Google Drive scopes. For details on Google Drive scopes, see Choose Google Drive API scopes in the Google developer documentation.

Integrate Google Drive

To integrate Google Drive with your Fire OS app, you must first integrate with the A3L Authentication SDK and implement the sign-in feature. For instructions, see Integrate A3L Authentication SDK. Add the Google Drive SDK as a dependency in your app's build.gradle file, as shown here.


Use version v3-rev20220709-2.0.0 or later of google-api-services-drive.

When you create the A3LSignInOptions object, request the appropriate scopes for Google Drive through the requestScopes() method, as shown in the following code.

A3LSignInOptions a3LSignInOptions = new A3LSignInOptions
.requestScopes(new Scope(DriveScopes.<SCOPE>))

Create credentials

After signing in the user, create credentials for Google Drive with an FOSAccountCredential object. When you create the object, pass the same scope that you passed for the A3LSignInOptions, as shown in the following example.

FOSAccountCredential fosAccountCredential = new FOSAccountCredential.usingOAuth2(context, Collections.singleton(DriveScopes.<SCOPE>));

Use this credential in your Google Drive builder, as shown here.

Drive googleDriveService = new Drive.Builder(new NetHttpTransport(),
                            new GsonFactory(),
                            .setApplicationName("<Your app name>")

Now you can use this Drive object with Google Drive API calls. The following code shows how to use the Drive object, and list the name and IDs of up to 10 files.

FileList result = googleDriveService.files().list()
     .setFields("nextPageToken, files(id, name)")
List<File> files = result.getFiles();
if (files == null || files.isEmpty()) {
  System.out.println("No files found.");
} else {
  for (File file : files) {
  System.out.printf("%s (%s)\n", file.getName(), file.getId());

Class differences

The following table lists the differences between the available methods in GoogleAccountCredential and FOSAccountCredential classes.

API Available in GoogleAccountCredential Available in FOSAccountCredential
static usingAudience(Context context, String audience) Yes No
static usingOAuth2(Context context, Collection<String> scopes) Yes Yes
Constructor (Context context, String scope) Yes Yes
getAllAccounts() Yes Yes
Returns only the account that was used to sign in
getBackOff() Yes Yes
getContext() Yes Yes
getGoogleAccountManager() Yes No
getScope() Yes Yes
getSelectedAccount() Yes Yes
getSelectedAccountName() Yes Yes
getSleeper() Yes Yes
getToken() Yes Yes
initialize(HttpRequest request) Yes Yes
newChooseAccountIntent() Yes No
setBackOff(BackOff backOff) Yes Yes
setSelectedAccount(Account selectedAccount) Yes Yes
setSelectedAccountName(String accountName) Yes Yes
setSleeper(Sleeper sleeper) Yes Yes

Last updated: Dec 05, 2023