Skip to content

update credentials documentation #1366

Description

@akostadinov

There is a problem with credentials documentation [1]. It points at oauth 2.0 [2] which refers to GoogleCredential [3]. And that is listed as Deprecated.

Please somebody update to a non-deprecated example.

[1] https://developers.google.com/api-client-library/java/google-api-java-client/dev-guide
[2] https://developers.google.com/api-client-library/java/google-api-java-client/oauth2
[3] https://googleapis.dev/java/google-api-client/latest/com/google/api/client/googleapis/auth/oauth2/GoogleCredential.html

Activity

  1. akostadinov commented on Aug 22, 2019

    @akostadinov
    Author

    This is what I figure out so far. Not yet sure how well it works but here I paste in groovy:

    import com.google.auth.oauth2.GoogleCredentials;
    import com.google.auth.oauth2.AccessToken;
    import com.google.auth.http.HttpCredentialsAdapter;
    
    import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
    import com.google.api.client.json.jackson2.JacksonFactory;
    
    GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream("/path/to/auth/gsheets.json")).createScoped(SheetsScopes.SPREADSHEETS);
    
    final String APPLICATION_NAME = "example app";
    
    Sheets sheets = new Sheets.Builder(
              GoogleNetHttpTransport.newTrustedTransport(),
              JacksonFactory.getDefaultInstance(),
              new HttpCredentialsAdapter(credentials)).
              setApplicationName(APPLICATION_NAME).
              build();
    

    Hope it helps somebody to get started quickly.

  2. added
    triage me
    🚨
    on Aug 23, 2019
  3. added
    type: docs
    on Aug 30, 2019
  4. removed
    🚨
    triage me
    on Aug 30, 2019
  5. stefan-zh commented on Sep 16, 2019

    @stefan-zh

    Thank you! It worked for me!

  6. self-assigned this
    on Dec 8, 2020
  7. chingor13 commented on Dec 10, 2020

    @chingor13
    Collaborator

    We also need to update the sample code to use the non-deprecated version.

  8. added a commit that references this issue on Dec 14, 2020
    1cd2a35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: docs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions