I've a requirement to run a background service to pull Youtube Analytics for already linked channel on a daily basis using [Youtube Analytics API](https://developers.google.com/youtube/analytics/reference/reports/query?apix=true&apix_params=%7B%22dimensions%22%3A%22video%22%2C%22endDate%22%3A%222018-05-01%22%2C%22ids%22%3A%22channel%3D%3DUC0wWN-Gq_fHMsUdvIevXTww%22%2C%22maxResults%22%3A10%2C%22metrics%22%3A%22estimatedMinutesWatched%2Cviews%2Clikes%2CsubscribersGained%22%2C%22sort%22%3A%22-estimatedMinutesWatched%22%2C%22startDate%22%3A%222017-01-01%22%7D)

Since it'll be in the background, having a direct accesses with Google's Oauth services would be good like with grant\_type client\_credentials.
But, the flow covered in all the samples [Provided here](https://github.com/youtube/api-samples/tree/master/java), needs an entire flow where user has to Authorize from browser using Authorisation Flow

```
 GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes).setCredentialDataStore(datastore)
            .build();

    // Build the local server and bind it to port 8080
    LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort(8080).build();

    // Authorize.
    return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user");

```

I've also tried working with an API key, but that is not supported by Analytics API.
Anybody knows any way to generate and retrieve access\_token based on a service account which allows backend job to consume Analytics API?