'GoogleCredentials reference not resolved with existing dependencies

In my ongoing attempt to securely create and use Oauth 2 tokens, I'm now trying to get the token via the following code:

    private static String getAccessToken() throws IOException {
    GoogleCredentials googleCredentials = GoogleCredentials
            .fromStream(new FileInputStream("service-account.json"))
            .createScoped(Arrays.asList(SCOPES));
    googleCredentials.refreshAccessToken();
    return googleCredentials.getAccessToken().getTokenValue();
}

However, GoogleCredentials isn't resolved. What dependency do I need to add to my app gradle file to resolve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source