Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: add migration explanation from the old com.google.api.client.googleapis.auth.oauth2.GoogleCredential class #657

Open
AndroidDeveloperLB opened this issue May 12, 2021 · 4 comments
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@AndroidDeveloperLB
Copy link

I've noticed the webpage of this repository doesn't explain how to leave the previous one :
https://googleapis.dev/java/google-api-client/latest/com/google/api/client/googleapis/auth/oauth2/GoogleCredential.html

Is your feature request related to a problem? Please describe.
Yes, I can't find the appropriate functions that match the previous ones. There is no documentation.

Describe the solution you'd like
To have such explanation.

Describe alternatives you've considered
Maybe write it on the old repository ?

I requested this here for the sample I've found, but it hasn't been updated for a very long time. I can't find a similar sample by Google

Additional context
The code I use (here) is very similar and based on what I've found of using the repository to reach the old API, here.

Would be very appreciated if you could tell me at least for these cases how to use them, or provide a nice sample that provides the same thing, of reaching People API.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 12, 2021

Here's a more updated code of what I use:
https://stackoverflow.com/q/67500479/878126

@Neenu1995 Neenu1995 added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label May 12, 2021
@dtotopus
Copy link

dtotopus commented May 20, 2021

I was following this official auth guide to work with google directory api and got into deprecated GoogleCredential issue as well.
In order to use GoogleCredentials instead of deprecated one to authenticate I did:

// Replaced GoogleCredential builder with GoogleCredentials
GoogleCredentials credentials = GoogleCredentials
    .fromStream(new FileInputStream("PATH_TO_CREDENTIALS.JSON"))
    .createScoped(DirectoryScopes.MY_SPECIFIC_DIRECTORY_SCOPE_ENUM)
    .createDelegated("IMPERSONATED_ACCOUNT_EMAIL");
credentials.refreshIfExpired();

// Now as old builder was returning different type - initialized HttpRequestInitializer
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(impersonated);

// Passed requestInitializer to Directory api Builder
Directory service = new Directory.Builder(httpTransport, jsonFactory, null).setHttpRequestInitializer(requestInitializer).build();
// Rest of it is just using Directory service in this case

Hope this helps

@AndroidDeveloperLB
Copy link
Author

@hmerdok The code I wrote seems to be more dependent (example is PeopleService.Builder) , but I hope what you wrote could help. I've set a reminder to check if indeed this helps

@AndroidDeveloperLB
Copy link
Author

@hmerdok How do I do this on Android though? How can I reach the json file there? I don't think it's really in the APK, no? And what's "DirectoryScopes.MY_SPECIFIC_DIRECTORY_SCOPE_ENUM" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants