├── .github ├── .release-please.yml ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── support_request.md ├── PULL_REQUEST_TEMPLATE.md ├── auto-label.yaml ├── blunderbuss.yml ├── dependabot.yml ├── release-please.yml ├── release-trigger.yml ├── snippet-bot.yml ├── sync-repo-settings.yaml ├── trusted-contribution.yml └── workflows │ ├── approve-readme.yaml │ ├── auto-release.yaml │ ├── ci.yaml │ ├── downstream.yaml │ ├── louhi-tag-release.yaml │ ├── renovate_config_check.yaml │ └── samples.yaml ├── .gitignore ├── .kokoro ├── build.bat ├── build.sh ├── coerce_logs.sh ├── common.cfg ├── common.sh ├── continuous │ ├── common.cfg │ ├── java10.cfg │ ├── java8.cfg │ ├── java9.cfg │ └── propose_release.sh ├── dependencies.sh ├── downstream-client-library-check.sh ├── nightly │ ├── common.cfg │ ├── integration.cfg │ ├── java11-integration.cfg │ ├── java11.cfg │ ├── java7.cfg │ ├── java8-osx.cfg │ ├── java8-win.cfg │ ├── java8.cfg │ └── samples.cfg ├── populate-secrets.sh ├── presubmit │ ├── clirr.cfg │ ├── common.cfg │ ├── dependencies.cfg │ ├── graalvm-native-17.cfg │ ├── graalvm-native.cfg │ ├── integration.cfg │ ├── java10.cfg │ ├── java11.cfg │ ├── java7.cfg │ ├── java8-osx.cfg │ ├── java8-win.cfg │ ├── java8.cfg │ ├── java9.cfg │ ├── linkage-monitor.cfg │ ├── lint.cfg │ └── samples.cfg ├── readme.sh └── trampoline.sh ├── .repo-metadata.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── checkstyle-suppressions.xml ├── checkstyle.xml ├── clirr-ignored-differences.xml ├── docs ├── _config.yml ├── _data │ └── navigation.yml ├── _layouts │ └── default.html ├── component-modules.md ├── index.md ├── oauth-1.0.md ├── oauth-2.0.md └── setup.md ├── findbugs-exclude.xml ├── google-oauth-client-appengine ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── extensions │ │ └── appengine │ │ └── auth │ │ ├── AbstractAppEngineCallbackServlet.java │ │ ├── AbstractAppEngineFlowServlet.java │ │ ├── AppEngineServletUtils.java │ │ ├── oauth2 │ │ ├── AbstractAppEngineAuthorizationCodeCallbackServlet.java │ │ ├── AbstractAppEngineAuthorizationCodeServlet.java │ │ ├── AppEngineCredentialStore.java │ │ ├── jakarta │ │ │ ├── AbstractAppEngineAuthorizationCodeCallbackServlet.java │ │ │ ├── AbstractAppEngineAuthorizationCodeServlet.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ └── package-info.java │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ └── appengine │ └── auth │ └── oauth2 │ └── AppEngineCredentialStoreTest.java ├── google-oauth-client-assembly ├── LICENSE.txt ├── README.md ├── assembly.xml ├── classpath-include ├── licenses │ ├── APACHE-LICENSE.txt │ ├── BSD-LICENSE.txt │ ├── CDDL-LICENSE.txt │ └── xpp3_LICENSE.txt ├── pom.xml ├── proguard-google-oauth-client.txt └── properties │ ├── google-http-client-android.jar.properties │ ├── google-http-client-gson.jar.properties │ ├── google-http-client-jackson2.jar.properties │ ├── google-http-client-xml.jar.properties │ ├── google-http-client.jar.properties │ ├── google-oauth-client.jar.properties │ └── gson.jar.properties ├── google-oauth-client-bom ├── README.md └── pom.xml ├── google-oauth-client-java6 ├── pom.xml ├── resources │ └── credentials.json └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── extensions │ │ └── java6 │ │ └── auth │ │ └── oauth2 │ │ ├── AbstractPromptReceiver.java │ │ ├── AuthorizationCodeInstalledApp.java │ │ ├── FileCredentialStore.java │ │ ├── FilePersistedCredential.java │ │ ├── FilePersistedCredentials.java │ │ ├── VerificationCodeReceiver.java │ │ └── package-info.java │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ └── java6 │ └── auth │ └── oauth2 │ └── FileCredentialStoreTest.java ├── google-oauth-client-jetty ├── pom.xml ├── resources │ └── credentials.json └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── extensions │ │ └── jetty │ │ └── auth │ │ └── oauth2 │ │ ├── LocalServerReceiver.java │ │ └── package-info.java │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ └── jetty │ └── auth │ └── oauth2 │ └── LocalServerReceiverTest.java ├── google-oauth-client-servlet ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ ├── auth │ └── helpers │ │ ├── Credential.java │ │ ├── ThreeLeggedFlow.java │ │ ├── oauth │ │ ├── OAuthHmacCredential.java │ │ ├── OAuthHmacThreeLeggedFlow.java │ │ └── package-info.java │ │ └── package-info.java │ └── servlet │ └── auth │ ├── AbstractCallbackServlet.java │ ├── AbstractFlowUserServlet.java │ ├── oauth2 │ ├── AbstractAuthorizationCodeCallbackServlet.java │ ├── AbstractAuthorizationCodeServlet.java │ ├── jakarta │ │ ├── AbstractAuthorizationCodeCallbackServlet.java │ │ ├── AbstractAuthorizationCodeServlet.java │ │ └── package-info.java │ └── package-info.java │ └── package-info.java ├── google-oauth-client ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── auth │ │ ├── oauth │ │ ├── AbstractOAuthGetToken.java │ │ ├── OAuthAuthorizeTemporaryTokenUrl.java │ │ ├── OAuthCallbackUrl.java │ │ ├── OAuthCredentialsResponse.java │ │ ├── OAuthGetAccessToken.java │ │ ├── OAuthGetTemporaryToken.java │ │ ├── OAuthHmacSha256Signer.java │ │ ├── OAuthHmacSigner.java │ │ ├── OAuthParameters.java │ │ ├── OAuthRsaSigner.java │ │ ├── OAuthSigner.java │ │ └── package-info.java │ │ ├── oauth2 │ │ ├── AuthorizationCodeFlow.java │ │ ├── AuthorizationCodeRequestUrl.java │ │ ├── AuthorizationCodeResponseUrl.java │ │ ├── AuthorizationCodeTokenRequest.java │ │ ├── AuthorizationRequestUrl.java │ │ ├── BearerToken.java │ │ ├── BrowserClientRequestUrl.java │ │ ├── ClientCredentialsTokenRequest.java │ │ ├── ClientParametersAuthentication.java │ │ ├── Credential.java │ │ ├── CredentialRefreshListener.java │ │ ├── CredentialStore.java │ │ ├── CredentialStoreRefreshListener.java │ │ ├── DataStoreCredentialRefreshListener.java │ │ ├── PasswordTokenRequest.java │ │ ├── RefreshTokenRequest.java │ │ ├── StoredCredential.java │ │ ├── TokenErrorResponse.java │ │ ├── TokenRequest.java │ │ ├── TokenResponse.java │ │ ├── TokenResponseException.java │ │ └── package-info.java │ │ └── openidconnect │ │ ├── Environment.java │ │ ├── HttpTransportFactory.java │ │ ├── IdToken.java │ │ ├── IdTokenResponse.java │ │ ├── IdTokenVerifier.java │ │ └── package-info.java │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── auth │ │ ├── oauth │ │ ├── OAuthHmacSha256SignerTest.java │ │ ├── OAuthHmacSignerTest.java │ │ ├── OAuthParametersTest.java │ │ └── OAuthRsaSignerTest.java │ │ ├── oauth2 │ │ ├── AuthenticationTestBase.java │ │ ├── AuthorizationCodeFlowTest.java │ │ ├── AuthorizationCodeRequestUrlTest.java │ │ ├── AuthorizationCodeResponseUrlTest.java │ │ ├── AuthorizationCodeTokenRequestTest.java │ │ ├── AuthorizationRequestUrlTest.java │ │ ├── BrowserClientRequestUrlTest.java │ │ ├── ClientCredentialsTokenRequestTest.java │ │ ├── ClientParametersAuthenticationTest.java │ │ ├── CredentialTest.java │ │ ├── CustomTokenRequestTest.java │ │ ├── CustomTokenResponseTest.java │ │ ├── PasswordTokenRequestTest.java │ │ ├── RefreshTokenRequestTest.java │ │ ├── TokenErrorResponseTest.java │ │ ├── TokenRequestTest.java │ │ └── TokenResponseTest.java │ │ └── openidconnect │ │ ├── IdTokenTest.java │ │ └── IdTokenVerifierTest.java │ └── resources │ ├── aws_security_credentials.json │ ├── certs.json │ ├── client_secret.json │ ├── com │ └── google │ │ └── api │ │ └── client │ │ └── auth │ │ └── security │ │ ├── secret.p12 │ │ └── secret.pem │ ├── federated_keys.json │ ├── iap_keys.json │ ├── legacy_federated_keys.json │ └── service_account_keys.json ├── pom.xml ├── renovate.json ├── samples ├── checkstyle.xml ├── dailymotion-cmdline-sample │ ├── README.md │ ├── instructions.html │ ├── logging.properties │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── services │ │ └── samples │ │ └── dailymotion │ │ └── cmdline │ │ ├── DailyMotionSample.java │ │ ├── DailyMotionUrl.java │ │ ├── OAuth2ClientCredentials.java │ │ ├── Video.java │ │ └── VideoFeed.java ├── install-without-bom │ └── pom.xml ├── keycloak-pkce-cmdline-sample │ ├── README.md │ ├── pom.xml │ ├── scripts │ │ └── initialize-keycloak.sh │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── services │ │ └── samples │ │ └── keycloak │ │ └── cmdline │ │ └── PKCESample.java ├── pom.xml ├── snapshot │ └── pom.xml └── snippets │ └── pom.xml └── versions.txt /.github/.release-please.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # For syntax help see: 5 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax 6 | 7 | # The @googleapis/cloud-java-team-teamsync is the default owner for changes in this repo 8 | * @googleapis/cloud-java-team-teamsync @googleapis/googleapis-auth 9 | 10 | 11 | # The java-samples-reviewers team is the default owner for samples changes 12 | samples/**/*.java @googleapis/java-samples-reviewers 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for stopping by to let us know something could be better! 2 | 3 | Please be sure to include as much information as possible: 4 | 5 | #### Environment details 6 | 7 | - OS: 8 | - Java version: 9 | - google-oauth-java-client version: 10 | 11 | #### Steps to reproduce 12 | 13 | 1. ? 14 | 2. ? 15 | 16 | #### Stacktrace 17 | 18 | ``` 19 | Any relevant stacktrace here. 20 | ``` 21 | 22 | #### External references such as API reference guides used 23 | 24 | - ? 25 | 26 | #### Any additional information below 27 | 28 | Making sure to follow these steps will guarantee the quickest resolution possible. 29 | 30 | Thanks! 31 | 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | Please run down the following list and make sure you've tried the usual "quick fixes": 12 | 13 | - Search the issues already opened: https://github.com/googleapis/google-oauth-java-client/issues 14 | - Check for answers on StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform 15 | 16 | If you are still having issues, please include as much information as possible: 17 | 18 | #### Environment details 19 | 20 | 1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). 21 | General, Core, and Other are also allowed as types 22 | 2. OS type and version: 23 | 3. Java version: 24 | 4. version(s): 25 | 26 | #### Steps to reproduce 27 | 28 | 1. ? 29 | 2. ? 30 | 31 | #### Code example 32 | 33 | ```java 34 | // example 35 | ``` 36 | 37 | #### Stack trace 38 | ``` 39 | Any relevant stacktrace here. 40 | ``` 41 | 42 | #### External references such as API reference guides 43 | 44 | - ? 45 | 46 | #### Any additional information below 47 | 48 | 49 | Following these steps guarantees the quickest resolution possible. 50 | 51 | Thanks! 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this library 4 | 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | What the problem is. Example: I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | What you want to happen. 16 | 17 | **Describe alternatives you've considered** 18 | Any alternative solutions or features you've considered. 19 | 20 | **Additional context** 21 | Any other context or screenshots about the feature request. 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. 4 | 5 | --- 6 | 7 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 2 | - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-oauth-java-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 3 | - [ ] Ensure the tests and linter pass 4 | - [ ] Code coverage does not decrease (if any source code was changed) 5 | - [ ] Appropriate docs were updated (if necessary) 6 | 7 | Fixes # ☕️ 8 | 9 | If you write sample code, please follow the [samples format]( 10 | https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md). 11 | -------------------------------------------------------------------------------- /.github/auto-label.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | requestsize: 15 | enabled: true 16 | -------------------------------------------------------------------------------- /.github/blunderbuss.yml: -------------------------------------------------------------------------------- 1 | # Configuration for the Blunderbuss GitHub app. For more info see 2 | # https://github.com/googleapis/repo-automation-bots/tree/main/packages/blunderbuss 3 | assign_prs_by: 4 | - labels: 5 | - samples 6 | to: 7 | - googleapis/java-samples-reviewers -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | # Disable version updates for Maven dependencies 8 | # we use renovate-bot as well as shared-dependencies BOM to update maven dependencies. 9 | ignore: 10 | - dependency-name: "*" 11 | - package-ecosystem: "pip" 12 | directory: "/" 13 | schedule: 14 | interval: "daily" 15 | # Disable version updates for pip dependencies 16 | # If a security vulnerability comes in, we will be notified about 17 | # it via template in the synthtool repository. 18 | ignore: 19 | - dependency-name: "*" 20 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | handleGHRelease: true 2 | releaseType: java-yoshi 3 | versioning: always-bump-minor 4 | tagPullRequestNumber: true 5 | branches: 6 | - bumpMinorPreMajor: true 7 | handleGHRelease: true 8 | releaseType: java-lts 9 | branch: 1.31.4-sp 10 | - bumpMinorPreMajor: true 11 | handleGHRelease: true 12 | releaseType: java-backport 13 | branch: 1.32.x 14 | - bumpMinorPreMajor: true 15 | handleGHRelease: true 16 | releaseType: java-backport 17 | branch: 1.33.x 18 | - handleGHRelease: true 19 | releaseType: java-backport 20 | versioning: always-bump-minor 21 | branch: 1.38.x 22 | -------------------------------------------------------------------------------- /.github/release-trigger.yml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | multiScmName: google-oauth-java-client 3 | -------------------------------------------------------------------------------- /.github/snippet-bot.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-oauth-java-client/e771f812900b03c37f50c2ec6376998a178ee8c3/.github/snippet-bot.yml -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | rebaseMergeAllowed: false 2 | squashMergeAllowed: true 3 | mergeCommitAllowed: false 4 | branchProtectionRules: 5 | - pattern: main 6 | isAdminEnforced: true 7 | requiredApprovingReviewCount: 1 8 | requiresCodeOwnerReviews: true 9 | requiresStrictStatusChecks: false 10 | requiredStatusCheckContexts: 11 | - checkstyle 12 | - units (8) 13 | - units (11) 14 | - dependencies (8) 15 | - dependencies (11) 16 | - clirr 17 | - cla/google 18 | - pattern: 1.31.4-sp 19 | isAdminEnforced: true 20 | requiredApprovingReviewCount: 1 21 | requiresCodeOwnerReviews: true 22 | requiresStrictStatusChecks: false 23 | requiredStatusCheckContexts: 24 | - checkstyle 25 | - units (8) 26 | - units (11) 27 | - dependencies (8) 28 | - dependencies (11) 29 | - clirr 30 | - cla/google 31 | - pattern: 1.32.x 32 | isAdminEnforced: true 33 | requiredApprovingReviewCount: 1 34 | requiresCodeOwnerReviews: true 35 | requiresStrictStatusChecks: false 36 | requiredStatusCheckContexts: 37 | - checkstyle 38 | - units (8) 39 | - units (11) 40 | - dependencies (8) 41 | - dependencies (11) 42 | - clirr 43 | - cla/google 44 | - pattern: 1.33.x 45 | isAdminEnforced: true 46 | requiredApprovingReviewCount: 1 47 | requiresCodeOwnerReviews: true 48 | requiresStrictStatusChecks: false 49 | requiredStatusCheckContexts: 50 | - checkstyle 51 | - units (8) 52 | - units (11) 53 | - dependencies (8) 54 | - dependencies (11) 55 | - clirr 56 | - cla/google 57 | - pattern: 1.38.x 58 | isAdminEnforced: true 59 | requiredApprovingReviewCount: 1 60 | requiresCodeOwnerReviews: true 61 | requiresStrictStatusChecks: false 62 | requiredStatusCheckContexts: 63 | - checkstyle 64 | - units (8) 65 | - units (11) 66 | - dependencies (8) 67 | - dependencies (11) 68 | - clirr 69 | - cla/google 70 | permissionRules: 71 | - team: yoshi-admins 72 | permission: admin 73 | - team: yoshi-java-admins 74 | permission: admin 75 | - team: yoshi-java 76 | permission: push 77 | - team: googleapis-auth 78 | permission: admin 79 | -------------------------------------------------------------------------------- /.github/trusted-contribution.yml: -------------------------------------------------------------------------------- 1 | trustedContributors: 2 | - renovate-bot 3 | - gcf-owl-bot[bot] 4 | -------------------------------------------------------------------------------- /.github/workflows/approve-readme.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # Github action job to test core java library features on 15 | # downstream client libraries before they are released. 16 | on: 17 | pull_request: 18 | name: auto-merge-readme 19 | jobs: 20 | approve: 21 | runs-on: ubuntu-latest 22 | if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' 23 | steps: 24 | - uses: actions/github-script@v7 25 | with: 26 | github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} 27 | script: | 28 | // only approve PRs from yoshi-automation 29 | if (context.payload.pull_request.user.login !== "yoshi-automation") { 30 | return; 31 | } 32 | 33 | // only approve PRs like "chore: release " 34 | if (!context.payload.pull_request.title === "chore: regenerate README") { 35 | return; 36 | } 37 | 38 | // only approve PRs with README.md and synth.metadata changes 39 | const files = new Set( 40 | ( 41 | await github.paginate( 42 | github.pulls.listFiles.endpoint({ 43 | owner: context.repo.owner, 44 | repo: context.repo.repo, 45 | pull_number: context.payload.pull_request.number, 46 | }) 47 | ) 48 | ).map(file => file.filename) 49 | ); 50 | if (files.size != 2 || !files.has("README.md") || !files.has(".github/readme/synth.metadata/synth.metadata")) { 51 | return; 52 | } 53 | 54 | // approve README regeneration PR 55 | await github.pulls.createReview({ 56 | owner: context.repo.owner, 57 | repo: context.repo.repo, 58 | body: 'Rubber stamped PR!', 59 | pull_number: context.payload.pull_request.number, 60 | event: 'APPROVE' 61 | }); 62 | 63 | // attach automerge label 64 | await github.issues.addLabels({ 65 | owner: context.repo.owner, 66 | repo: context.repo.repo, 67 | issue_number: context.payload.pull_request.number, 68 | labels: ['automerge'] 69 | }); 70 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: ci 7 | jobs: 8 | units: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | java: [8, 11, 17] 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: actions/setup-java@v1 17 | with: 18 | java-version: ${{matrix.java}} 19 | - run: java -version 20 | - run: .kokoro/build.sh 21 | env: 22 | JOB_TYPE: test 23 | dependencies: 24 | runs-on: ubuntu-latest 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | java: [8, 11, 17] 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: actions/setup-java@v1 32 | with: 33 | java-version: ${{matrix.java}} 34 | - run: java -version 35 | - run: .kokoro/dependencies.sh 36 | lint: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | - uses: actions/setup-java@v1 41 | with: 42 | java-version: 11 43 | - run: java -version 44 | - run: .kokoro/build.sh 45 | env: 46 | JOB_TYPE: lint 47 | clirr: 48 | runs-on: ubuntu-latest 49 | steps: 50 | - uses: actions/checkout@v2 51 | - uses: actions/setup-java@v1 52 | with: 53 | java-version: 8 54 | - run: java -version 55 | - run: .kokoro/build.sh 56 | env: 57 | JOB_TYPE: clirr 58 | 59 | units-java21: 60 | # Building using Java 8 and run the tests with Java 21 runtime 61 | name: "units (21)" 62 | runs-on: ubuntu-latest 63 | steps: 64 | - uses: actions/checkout@v3 65 | - uses: actions/setup-java@v3 66 | with: 67 | java-version: 21 68 | distribution: temurin 69 | - name: "Set jvm system property environment variable for surefire plugin (unit tests)" 70 | # Maven surefire plugin (unit tests) allows us to specify JVM to run the tests. 71 | # https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm 72 | run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java" >> $GITHUB_ENV 73 | shell: bash 74 | - uses: actions/setup-java@v3 75 | with: 76 | java-version: 8 77 | distribution: temurin 78 | - run: .kokoro/build.sh 79 | env: 80 | JOB_TYPE: test 81 | -------------------------------------------------------------------------------- /.github/workflows/louhi-tag-release.yaml: -------------------------------------------------------------------------------- 1 | name: Louhi Release Tag 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | permissions: 12 | # Permission to create tag 13 | # https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-contents 14 | contents: write 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v4 18 | with: 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | - name: Set up Git 21 | run: | 22 | git config --local user.email "action@github.com" 23 | git config --local user.name "Louhi Release Tag" 24 | - name: Fetch all tags 25 | run: git fetch --tags 26 | - name: Create additional tags 27 | shell: bash 28 | env: 29 | GH_TOKEN: ${{ github.token }} 30 | run: | 31 | SHA=$(git log -1 --format=format:%H) 32 | PR_NUMBER=$(gh pr list --search "$SHA" --state merged --json number --jq '.[].number') 33 | if [[ -z "${PR_NUMBER}" ]]; then 34 | echo "Couldn't get pull request number for ${SHA}" 35 | exit 1 36 | fi 37 | echo "PR ${PR_NUMBER} for ${SHA}" 38 | TAG_NAME="louhi-${PR_NUMBER}" 39 | git tag $TAG_NAME 40 | git push origin $TAG_NAME 41 | -------------------------------------------------------------------------------- /.github/workflows/renovate_config_check.yaml: -------------------------------------------------------------------------------- 1 | name: Renovate Bot Config Validation 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - 'renovate.json' 7 | 8 | jobs: 9 | renovate_bot_config_validation: 10 | runs-on: ubuntu-22.04 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | 16 | - name: Set up Node.js 17 | uses: actions/setup-node@v4 18 | with: 19 | node-version: '20' 20 | 21 | - name: Install Renovate and Config Validator 22 | run: | 23 | npm install -g npm@latest 24 | npm install --global renovate 25 | renovate-config-validator 26 | -------------------------------------------------------------------------------- /.github/workflows/samples.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # Github action job to test core java library features on 15 | # downstream client libraries before they are released. 16 | on: 17 | pull_request: 18 | name: samples 19 | jobs: 20 | checkstyle: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v4 24 | - uses: actions/setup-java@v4 25 | with: 26 | distribution: temurin 27 | java-version: 8 28 | - name: Run checkstyle 29 | run: mvn -P lint --quiet --batch-mode checkstyle:check 30 | working-directory: samples/snippets 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | bin/ 3 | .settings/ 4 | .classpath 5 | .project 6 | .idea/ 7 | *.iml 8 | .checkstyle 9 | .factorypath 10 | 11 | # MacOS 12 | .DS_Store 13 | 14 | # VS Code 15 | .vscode/ 16 | 17 | -------------------------------------------------------------------------------- /.kokoro/build.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2022 Google LLC 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | :: Github action job to test core java library features on 15 | :: downstream client libraries before they are released. 16 | :: See documentation in type-shell-output.bat 17 | 18 | "C:\Program Files\Git\bin\bash.exe" %~dp0build.sh 19 | -------------------------------------------------------------------------------- /.kokoro/coerce_logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2019 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This script finds and moves sponge logs so that they can be found by placer 17 | # and are not flagged as flaky by sponge. 18 | 19 | set -eo pipefail 20 | 21 | ## Get the directory of the build script 22 | scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 23 | ## cd to the parent directory, i.e. the root of the git repo 24 | cd ${scriptDir}/.. 25 | 26 | job=$(basename ${KOKORO_JOB_NAME}) 27 | 28 | echo "coercing sponge logs..." 29 | for xml in `find . -name *-sponge_log.xml` 30 | do 31 | class=$(basename ${xml} | cut -d- -f2) 32 | dir=$(dirname ${xml})/${job}/${class} 33 | text=$(dirname ${xml})/${class}-sponge_log.txt 34 | mkdir -p ${dir} 35 | mv ${xml} ${dir}/sponge_log.xml 36 | mv ${text} ${dir}/sponge_log.txt 37 | done 38 | -------------------------------------------------------------------------------- /.kokoro/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} 4 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 5 | 6 | # All builds use the trampoline script to run in docker. 7 | build_file: "google-oauth-java-client/.kokoro/trampoline.sh" 8 | 9 | # Tell the trampoline which build file to use. 10 | env_vars: { 11 | key: "TRAMPOLINE_BUILD_FILE" 12 | value: "github/google-oauth-java-client/.kokoro/build.sh" 13 | } 14 | -------------------------------------------------------------------------------- /.kokoro/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | function retry_with_backoff { 17 | attempts_left=$1 18 | sleep_seconds=$2 19 | shift 2 20 | command=$@ 21 | 22 | 23 | # store current flag state 24 | flags=$- 25 | 26 | # allow a failures to continue 27 | set +e 28 | ${command} 29 | exit_code=$? 30 | 31 | # restore "e" flag 32 | if [[ ${flags} =~ e ]] 33 | then set -e 34 | else set +e 35 | fi 36 | 37 | if [[ $exit_code == 0 ]] 38 | then 39 | return 0 40 | fi 41 | 42 | # failure 43 | if [[ ${attempts_left} > 0 ]] 44 | then 45 | echo "failure (${exit_code}), sleeping ${sleep_seconds}..." 46 | sleep ${sleep_seconds} 47 | new_attempts=$((${attempts_left} - 1)) 48 | new_sleep=$((${sleep_seconds} * 2)) 49 | retry_with_backoff ${new_attempts} ${new_sleep} ${command} 50 | fi 51 | 52 | return $exit_code 53 | } 54 | 55 | ## Helper functionss 56 | function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } 57 | function msg() { println "$*" >&2; } 58 | function println() { printf '%s\n' "$(now) $*"; } 59 | 60 | ## Helper comment to trigger updated repo dependency release -------------------------------------------------------------------------------- /.kokoro/continuous/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-oauth-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-oauth-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | -------------------------------------------------------------------------------- /.kokoro/continuous/java10.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java10" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/continuous/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/continuous/java9.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java9" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/continuous/propose_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=/home/node/.npm-global 20 | 21 | if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then 22 | # Groom the release PR as new commits are merged. 23 | npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ 24 | --repo-url=googleapis/google-oauth-java-client \ 25 | --package-name="google-oauth-client" \ 26 | --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ 27 | --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ 28 | --release-type=java-yoshi 29 | fi 30 | -------------------------------------------------------------------------------- /.kokoro/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2019 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | shopt -s nullglob 18 | 19 | ## Get the directory of the build script 20 | scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 21 | ## cd to the parent directory, i.e. the root of the git repo 22 | cd ${scriptDir}/.. 23 | 24 | # include common functions 25 | source ${scriptDir}/common.sh 26 | 27 | # Print out Java 28 | java -version 29 | echo $JOB_TYPE 30 | 31 | function determineMavenOpts() { 32 | local javaVersion=$( 33 | # filter down to the version line, then pull out the version between quotes, 34 | # then trim the version number down to its minimal number (removing any 35 | # update or suffix number). 36 | java -version 2>&1 | grep "version" \ 37 | | sed -E 's/^.*"(.*?)".*$/\1/g' \ 38 | | sed -E 's/^(1\.[0-9]\.0).*$/\1/g' 39 | ) 40 | 41 | if [[ $javaVersion == 17* ]] 42 | then 43 | # MaxPermSize is no longer supported as of jdk 17 44 | echo -n "-Xmx1024m" 45 | else 46 | echo -n "-Xmx1024m -XX:MaxPermSize=128m" 47 | fi 48 | } 49 | 50 | export MAVEN_OPTS=$(determineMavenOpts) 51 | 52 | # this should run maven enforcer 53 | retry_with_backoff 3 10 \ 54 | mvn install -B -V -ntp \ 55 | -DskipTests=true \ 56 | -Dmaven.javadoc.skip=true \ 57 | -Dclirr.skip=true 58 | 59 | mvn -B dependency:analyze -DfailOnWarning=true 60 | -------------------------------------------------------------------------------- /.kokoro/nightly/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-oauth-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-oauth-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | -------------------------------------------------------------------------------- /.kokoro/nightly/integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | # TODO: remove this after we've migrated all tests and scripts 14 | env_vars: { 15 | key: "GCLOUD_PROJECT" 16 | value: "java-docs-samples-testing" 17 | } 18 | 19 | env_vars: { 20 | key: "GOOGLE_CLOUD_PROJECT" 21 | value: "java-docs-samples-testing" 22 | } 23 | 24 | env_vars: { 25 | key: "ENABLE_FLAKYBOT" 26 | value: "true" 27 | } 28 | 29 | env_vars: { 30 | key: "GOOGLE_APPLICATION_CREDENTIALS" 31 | value: "secret_manager/java-it-service-account" 32 | } 33 | 34 | env_vars: { 35 | key: "SECRET_MANAGER_KEYS" 36 | value: "java-it-service-account" 37 | } 38 | 39 | -------------------------------------------------------------------------------- /.kokoro/nightly/java11-integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-public-resources/java11014" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | # TODO: remove this after we've migrated all tests and scripts 14 | env_vars: { 15 | key: "GCLOUD_PROJECT" 16 | value: "gcloud-devel" 17 | } 18 | 19 | env_vars: { 20 | key: "GOOGLE_CLOUD_PROJECT" 21 | value: "gcloud-devel" 22 | } 23 | 24 | env_vars: { 25 | key: "ENABLE_FLAKYBOT" 26 | value: "true" 27 | } 28 | 29 | env_vars: { 30 | key: "GOOGLE_APPLICATION_CREDENTIALS" 31 | value: "secret_manager/java-it-service-account" 32 | } 33 | 34 | env_vars: { 35 | key: "SECRET_MANAGER_KEYS" 36 | value: "java-it-service-account" 37 | } 38 | 39 | -------------------------------------------------------------------------------- /.kokoro/nightly/java11.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java11" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/nightly/java7.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java7" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8-osx.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-oauth-java-client/.kokoro/build.sh" 4 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8-win.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-oauth-java-client/.kokoro/build.bat" 4 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/nightly/samples.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "samples" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "java-docs-samples-testing" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "java-docs-samples-testing" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-docs-samples-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-docs-samples-service-account" 33 | } 34 | 35 | env_vars: { 36 | key: "ENABLE_FLAKYBOT" 37 | value: "true" 38 | } 39 | -------------------------------------------------------------------------------- /.kokoro/populate-secrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | 18 | function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} 19 | function msg { println "$*" >&2 ;} 20 | function println { printf '%s\n' "$(now) $*" ;} 21 | 22 | 23 | # Populates requested secrets set in SECRET_MANAGER_KEYS from service account: 24 | # kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com 25 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 26 | msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" 27 | mkdir -p ${SECRET_LOCATION} 28 | for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") 29 | do 30 | msg "Retrieving secret ${key}" 31 | docker run --entrypoint=gcloud \ 32 | --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ 33 | gcr.io/google.com/cloudsdktool/cloud-sdk \ 34 | secrets versions access latest \ 35 | --project cloud-devrel-kokoro-resources \ 36 | --secret ${key} > \ 37 | "${SECRET_LOCATION}/${key}" 38 | if [[ $? == 0 ]]; then 39 | msg "Secret written to ${SECRET_LOCATION}/${key}" 40 | else 41 | msg "Error retrieving secret ${key}" 42 | fi 43 | done 44 | -------------------------------------------------------------------------------- /.kokoro/presubmit/clirr.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | 5 | env_vars: { 6 | key: "TRAMPOLINE_IMAGE" 7 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 8 | } 9 | 10 | env_vars: { 11 | key: "JOB_TYPE" 12 | value: "clirr" 13 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-oauth-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-oauth-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | 27 | before_action { 28 | fetch_keystore { 29 | keystore_resource { 30 | keystore_config_id: 73713 31 | keyname: "dpebot_codecov_token" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.kokoro/presubmit/dependencies.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "TRAMPOLINE_BUILD_FILE" 11 | value: "github/google-oauth-java-client/.kokoro/dependencies.sh" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/presubmit/graalvm-native-17.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/graalvm17:22.3.3" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "graalvm17" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "gcloud-devel" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "gcloud-devel" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-it-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-it-service-account" 33 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/graalvm-native.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/graalvm:22.3.3" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "graalvm" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "gcloud-devel" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "gcloud-devel" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-it-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-it-service-account" 33 | } 34 | -------------------------------------------------------------------------------- /.kokoro/presubmit/integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "gcloud-devel" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "gcloud-devel" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-it-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-it-service-account" 33 | } 34 | 35 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java10.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java10" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java11.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java11" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java7.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java7" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8-osx.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-oauth-java-client/.kokoro/build.sh" 4 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8-win.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-oauth-java-client/.kokoro/build.bat" 4 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java9.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java9" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/linkage-monitor.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "TRAMPOLINE_BUILD_FILE" 11 | value: "github/google-oauth-java-client/.kokoro/linkage-monitor.sh" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/lint.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | 5 | env_vars: { 6 | key: "TRAMPOLINE_IMAGE" 7 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 8 | } 9 | 10 | env_vars: { 11 | key: "JOB_TYPE" 12 | value: "lint" 13 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/samples.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "samples" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "java-docs-samples-testing" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "java-docs-samples-testing" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-docs-samples-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-docs-samples-service-account" 33 | } -------------------------------------------------------------------------------- /.kokoro/readme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | 18 | cd ${KOKORO_ARTIFACTS_DIR}/github/google-oauth-java-client 19 | 20 | # Disable buffering, so that the logs stream through. 21 | export PYTHONUNBUFFERED=1 22 | 23 | # Kokoro exposes this as a file, but the scripts expect just a plain variable. 24 | export GITHUB_TOKEN=$(cat ${KOKORO_KEYSTORE_DIR}/73713_yoshi-automation-github-key) 25 | 26 | # Setup git credentials 27 | echo "https://${GITHUB_TOKEN}:@github.com" >> ~/.git-credentials 28 | git config --global credential.helper 'store --file ~/.git-credentials' 29 | 30 | python3.6 -m pip install git+https://github.com/googleapis/synthtool.git#egg=gcp-synthtool 31 | 32 | set +e 33 | python3.6 -m autosynth.synth \ 34 | --repository=googleapis/google-oauth-java-client \ 35 | --synth-file-name=.github/readme/synth.py \ 36 | --metadata-path=.github/readme/synth.metadata \ 37 | --pr-title="chore: regenerate README" \ 38 | --branch-suffix="readme" 39 | 40 | # autosynth returns 28 to signal there are no changes 41 | RETURN_CODE=$? 42 | if [[ ${RETURN_CODE} -ne 0 && ${RETURN_CODE} -ne 28 ]] 43 | then 44 | exit ${RETURN_CODE} 45 | fi 46 | -------------------------------------------------------------------------------- /.kokoro/trampoline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2018 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | set -eo pipefail 16 | # Always run the cleanup script, regardless of the success of bouncing into 17 | # the container. 18 | function cleanup() { 19 | chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 20 | ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 21 | echo "cleanup"; 22 | } 23 | trap cleanup EXIT 24 | 25 | $(dirname $0)/populate-secrets.sh # Secret Manager secrets. 26 | python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" 27 | -------------------------------------------------------------------------------- /.repo-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_shortname": "google-oauth-client", 3 | "name_pretty": "Google OAuth Java Client", 4 | "client_documentation": "https://googleapis.dev/java/google-oauth-client/latest/", 5 | "release_level": "stable", 6 | "language": "java", 7 | "repo": "googleapis/google-oauth-java-client", 8 | "repo_short": "google-oauth-java-client", 9 | "library_type": "AUTH", 10 | "distribution_name": "com.google.oauth-client:google-oauth-client", 11 | "codeowner_team": "@googleapis/googleapis-auth" 12 | } 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows 28 | [Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). 29 | 30 | ## Building the project 31 | 32 | To build, package, and run all unit tests run the command 33 | 34 | ``` 35 | mvn clean verify 36 | ``` 37 | 38 | ### Running Integration tests 39 | 40 | To include integration tests when building the project, you need access to 41 | a GCP Project with a valid service account. 42 | 43 | For instructions on how to generate a service account and corresponding 44 | credentials JSON see: [Creating a Service Account][1]. 45 | 46 | Then run the following to build, package, run all unit tests and run all 47 | integration tests. 48 | 49 | ```bash 50 | export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json 51 | mvn -Penable-integration-tests clean verify 52 | ``` 53 | 54 | ## Code Samples 55 | 56 | All code samples must be in compliance with the [java sample formatting guide][3]. 57 | Code Samples must be bundled in separate Maven modules. 58 | 59 | The samples must be separate from the primary project for a few reasons: 60 | 1. Primary projects have a minimum Java version of Java 8 whereas samples can have 61 | Java version of Java 11. Due to this we need the ability to 62 | selectively exclude samples from a build run. 63 | 2. Many code samples depend on external GCP services and need 64 | credentials to access the service. 65 | 3. Code samples are not released as Maven artifacts and must be excluded from 66 | release builds. 67 | 68 | ### Building 69 | 70 | ```bash 71 | mvn clean verify 72 | ``` 73 | 74 | Some samples require access to GCP services and require a service account: 75 | 76 | ```bash 77 | export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json 78 | mvn clean verify 79 | ``` 80 | 81 | ### Code Formatting 82 | 83 | Code in this repo is formatted with 84 | [google-java-format](https://github.com/google/google-java-format). 85 | To run formatting on your project, you can run: 86 | ``` 87 | mvn com.coveo:fmt-maven-plugin:format 88 | ``` 89 | 90 | [1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account 91 | [2]: https://maven.apache.org/settings.html#Active_Profiles 92 | [3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google OAuth Client Library for Java 2 | 3 | ## Library maintenance 4 | 5 | This client library is supported but in maintenance mode only. We are fixing necessary bugs and 6 | adding essential features to ensure this library continues to meet your needs for accessing Google 7 | APIs. Non-critical issues will be closed. Any issue may be reopened if it is causing ongoing 8 | problems. 9 | 10 | ## Description 11 | 12 | Written by Google, the Google OAuth Client Library for Java is a powerful and easy-to-use Java 13 | library for the OAuth 1.0a and OAuth 2.0 authorization standards. The Google OAuth Client Library 14 | for Java is designed to work with any OAuth service on the web, not just with Google APIs. It is 15 | built on the [Google HTTP Client Library for Java](https://github.com/googleapis/google-http-java-client). 16 | 17 | The library supports the following Java environments: 18 | 19 | - Java 7 (or higher) 20 | - Android 4.0 (Ice Cream Sandwich) (or higher) 21 | - Google App Engine 22 | 23 | For access to Google APIs, see the 24 | [Google APIs Client Library for Java](https://github.com/googleapis/google-api-java-client). 25 | 26 | This is an open-source library, and [contributions](CONTRIBUTING.md) are welcome. 27 | 28 | ## Documentation 29 | 30 | - [Developer's Guide](https://googleapis.github.io/google-oauth-java-client/index.html) 31 | - [Setup Instructions](https://googleapis.github.io/google-oauth-java-client/setup.html) 32 | - [Samples](https://github.com/googleapis/google-oauth-java-client/tree/main/samples) 33 | - [JavaDoc](https://googleapis.dev/java/google-oauth-client/latest/) 34 | - [Release Notes](https://github.com/googleapis/google-oauth-java-client/releases) 35 | - [Support (Questions, Bugs)](https://github.com/googleapis/google-oauth-java-client/issues) 36 | 37 | ## CI Status 38 | 39 | Java Version | Status 40 | ------------ | ------ 41 | Java 7 | [![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java7.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java7.html) 42 | Java 8 | [![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java8.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java8.html) 43 | Java 11 | [![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java11.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-oauth-java-client/java11.html) 44 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /clirr-ignored-differences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-dinky 2 | title: Google OAuth Client for Java 3 | -------------------------------------------------------------------------------- /docs/_data/navigation.yml: -------------------------------------------------------------------------------- 1 | toc: 2 | - page: Overview 3 | url: index.html 4 | - page: Setup Instructions 5 | url: setup.html 6 | - page: Component Modules 7 | url: component-modules.html 8 | - page: OAuth 1.0 9 | url: oauth-1.0.html 10 | - page: OAuth 2.0 11 | url: oauth-2.0.html 12 | -------------------------------------------------------------------------------- /docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {% seo %} 8 | 9 | 10 | 11 | 14 | 15 | 16 |
17 |
18 |

{{ site.title | default: site.github.repository_name }}

19 | 20 | {% for entry in site.data.navigation.toc %} 21 | {{ entry.page }}
22 | {% endfor %} 23 |
24 | 25 | 32 |
33 | 34 |
35 | {{ content }} 36 |
37 | 38 | 41 |
42 | 43 | {% if site.google_analytics %} 44 | 52 | {% endif %} 53 | 54 | -------------------------------------------------------------------------------- /docs/component-modules.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Component Modules 3 | --- 4 | 5 | # Component Modules 6 | 7 | This libraries is composed of several modules: 8 | 9 | ## google-oauth-client 10 | 11 | Google OAuth Client Library for Java (`google-oauth-client`) is designed to be 12 | compatible with all supported Java platforms, including Android. 13 | 14 | ## google-oauth-client-appengine 15 | 16 | Google App Engine extensions to the Google OAuth Client Library for Java 17 | (`google-oauth-client-appengine`) support Java Google App Engine applications. 18 | This module depends on `google-oauth-client` and `google-oauth-client-servlet`. 19 | 20 | ## google-oauth-client-java6 21 | 22 | Java 6 (and higher) extensions to the Google OAuth Client Library for Java 23 | (`google-oauth-client-java6`) support Java6+ applications. This module depends 24 | on `google-oauth-client`. 25 | 26 | ## google-oauth-client-jetty 27 | 28 | Jetty extensions to the Google OAuth Client Library for Java 29 | (`google-oauth-client-jetty`) support authorization code flow for installed 30 | applications. This module depends on `google-oauth-client-java6`. 31 | 32 | ## google-oauth-client-servlet 33 | 34 | Servlet and JDO extensions to the Google OAuth Client Library for Java 35 | (`google-oauth-client-servlet`) support Java servlet web applications. This 36 | module depends on `google-oauth-client`. 37 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | 5 | # Overview 6 | 7 | ## Description 8 | 9 | Written by Google, the Google OAuth Client Library for Java is a 10 | powerful and easy-to-use Java library for the OAuth 1.0a and OAuth 2.0 11 | authorization standards. 12 | 13 | The Google OAuth Client Library for Java is designed to work with any 14 | OAuth service on the web, not just with Google APIs. The library is 15 | built on the [Google HTTP Client Library for Java][google-http-client], 16 | and it supports Java 7 (or higher) standard (SE) and enterprise (EE), 17 | Android 4.0 (or higher), and Google App Engine. 18 | 19 | For access to Google APIs, see the 20 | [Google API Client Library for Java][google-api-client]. 21 | 22 | This is an open-source library, and you can access the 23 | [source on GitHub][google-oauth-client]. [Contributions][contributions] are 24 | welcome. 25 | 26 | ## Beta Features 27 | 28 | Features marked with the `@Beta` annotation at the class or method level 29 | are subject to change. They might be modified in any way, or even removed, 30 | in any major release. You should not use beta features if your code is a 31 | library itself (that is, if your code is used on the `CLASSPATH` of users 32 | outside your own control). 33 | 34 | ## Deprecated Features 35 | 36 | Deprecated non-beta features will be removed eighteen months after the 37 | release in which they are first deprecated. You must fix your usages before 38 | this time. If you don't, any type of breakage might result, and you are not 39 | guaranteed a compilation error. 40 | 41 | [google-http-client]: https://github.com/googleapis/google-http-java-client 42 | [google-api-client]: https://github.com/googleapis/google-api-java-client 43 | [google-oauth-client]: https://github.com/googleapis/google-oauth-java-client 44 | [contributions]: https://github.com/googleapis/google-oauth-java-client/blob/master/CONTRIBUTING.md -------------------------------------------------------------------------------- /docs/oauth-1.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: OAuth 1.0 3 | --- 4 | 5 | # OAuth 1.0a and the Google OAuth Client Library for Java 6 | 7 | [OAuth 1.0][oauth1] is a standard specification for allowing end users to 8 | securely authorize a client application to access protected server-side 9 | resources. 10 | 11 | ## Important notices 12 | 13 | The OAuth 1.0a support provided by the Google OAuth Client Library for Java is 14 | `@Beta`. 15 | 16 | Do not use OAuth 1.0 to access Google APIs, because Google has deprecated its 17 | support for OAuth 1.0 in favor of OAuth 2.0. If you currently have an app that 18 | accesses Google APIs using OAuth 1.0, see 19 | [Migrating from OAuth 1.0 to OAuth 2.0][migrating]. 20 | 21 | ## Using OAuth 1.0 22 | 23 | The Google OAuth Client Library for Java supports two types of signature methods 24 | for OAuth 1.0a (`@Beta`), which we provide foruse with non-Google services: 25 | 26 | * HMAC-SHA1 ([`OAuthHmacSigner`][oauth-hmac-signer]) 27 | * RSA-SHA1 ([`OAuthRsaSigner`][oauth-rsa-signer] 28 | 29 | For details, see the 30 | [Javadoc for the OAuth 1.0 package][oauth-javadoc]. 31 | 32 | [oauth1]: http://tools.ietf.org/html/rfc5849 33 | [migrating]: https://developers.google.com/accounts/docs/OAuth_ref#migration 34 | [oauth-hmac-signer]: https://googleapis.dev/java/google-oauth-client/latest/com/google/api/client/auth/oauth/OAuthHmacSigner.html 35 | [oauth-rsa-signer]: https://googleapis.dev/java/google-oauth-client/latest/com/google/api/client/auth/oauth/OAuthRsaSigner.html 36 | [oauth-javadoc]: (https://googleapis.dev/java/google-oauth-client/latest/com/google/api/client/auth/oauth/package-summary.html) 37 | -------------------------------------------------------------------------------- /docs/setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Setup Instructions 3 | --- 4 | 5 | # Setup Instructions 6 | 7 | You can download the Google OAuth Client Library for Java and its dependencies 8 | in a zip file, or you can use a dependency manager such as Maven or gradle to 9 | install the necessary jars from the Maven Central repository. 10 | 11 | ## Maven 12 | 13 | The Google OAuth Client Library for Java is in the central Maven repository. The 14 | Maven `groupId` for all artifacts for this library is `com.google.oauth-client`. 15 | 16 | To ensure all dependency versions work together and to avoid having to manually 17 | choose and specify versions for each dependency, we recommend first importing 18 | the `com.google.cloud:libraries-bom` in the `dependencyManagement` section of 19 | your `pom.xml`: 20 | 21 | ```xml 22 | 23 | 24 | 25 | com.google.cloud 26 | libraries-bom 27 | 2.2.0 28 | pom 29 | import 30 | 31 | 32 | 33 | ``` 34 | 35 | Then you add the individual dependencies you need without version numbers to the 36 | `dependencies` section: 37 | 38 | ```xml 39 | 40 | com.google.oauth-client 41 | google-oauth-client 42 | 43 | ``` 44 | 45 | On Android, you may need to explicitly exclude unused dependencies: 46 | 47 | ```xml 48 | 49 | com.google.oauth-client 50 | google-oauth-client 51 | 52 | 53 | xpp3 54 | xpp3 55 | 56 | 57 | httpclient 58 | org.apache.httpcomponents 59 | 60 | 61 | junit 62 | junit 63 | 64 | 65 | android 66 | com.google.android 67 | 68 | 69 | 70 | ``` 71 | 72 | ## Download the library with dependencies 73 | 74 | Download the latest assembly zip file from Maven Central and extract it on your 75 | computer. This zip contains the client library class jar files and the 76 | associated source jar files for each artifact and their dependencies. You can 77 | find dependency graphs and licenses for the different libraries in the 78 | dependencies folder. For more details about the contents of the download, see 79 | the contained `readme.html` file. 80 | -------------------------------------------------------------------------------- /findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/AbstractAppEngineCallbackServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.auth; 16 | 17 | import com.google.api.client.extensions.appengine.http.UrlFetchTransport; 18 | import com.google.api.client.extensions.servlet.auth.AbstractCallbackServlet; 19 | import com.google.api.client.http.HttpTransport; 20 | import com.google.api.client.util.Beta; 21 | 22 | /** 23 | * {@link Beta}
24 | * This servlet fills in some of the required information for the {@link AbstractCallbackServlet} 25 | * with reasonable defaults for App Engine. It will default the servlet to creating {@link 26 | * UrlFetchTransport} objects whenever an {@link HttpTransport} is needed. It will also default the 27 | * user identifier to the logged in App Engine user. This servlet requires that the App Engine user 28 | * must be logged in to work correctly. This can be accomplished by adding a security constraint in 29 | * your web.xml for the path at which this servlet will live. 30 | * 31 | *

Example that requires login for all pages: 32 | * 33 | *

34 |  * 
35 |  * <security-constraint>
36 |  * <web-resource-collection>
37 |  * <web-resource-name>any</web-resource-name>
38 |  * <url-pattern>/*</url-pattern>
39 |  * </web-resource-collection>
40 |  * <auth-constraint>
41 |  * <role-name>*</role-name>
42 |  * </auth-constraint>
43 |  * </security-constraint>
44 |  * 
45 |  * 
46 | * 47 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 48 | * {@link 49 | * com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeCallbackServlet}. 50 | * 51 | * @author moshenko@google.com (Jacob Moshenko) 52 | * @since 1.4 53 | */ 54 | @Beta 55 | public abstract class AbstractAppEngineCallbackServlet extends AbstractCallbackServlet { 56 | 57 | private static final long serialVersionUID = 1L; 58 | 59 | /** 60 | * Return the user ID of the user that is logged in. 61 | * 62 | * @throws IllegalStateException Thrown when no user is logged in. 63 | */ 64 | @Override 65 | protected String getUserId() { 66 | return AppEngineServletUtils.getUserId(); 67 | } 68 | 69 | @Override 70 | protected HttpTransport newHttpTransportInstance() { 71 | return new UrlFetchTransport(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/AbstractAppEngineFlowServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.auth; 16 | 17 | import com.google.api.client.extensions.appengine.http.UrlFetchTransport; 18 | import com.google.api.client.extensions.servlet.auth.AbstractFlowUserServlet; 19 | import com.google.api.client.http.HttpTransport; 20 | import com.google.api.client.util.Beta; 21 | 22 | /** 23 | * {@link Beta}
24 | * This class fills in some of the unknowns of the generic {@link AbstractFlowUserServlet} with 25 | * reasonable defaults for App Engine. This servlet requires that the App Engine user must be logged 26 | * in to work correctly. 27 | * 28 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 29 | * {@link 30 | * com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeServlet}. 31 | * 32 | * @author moshenko@google.com (Jacob Moshenko) 33 | * @since 1.4 34 | */ 35 | @Beta 36 | public abstract class AbstractAppEngineFlowServlet extends AbstractFlowUserServlet { 37 | 38 | private static final long serialVersionUID = 1L; 39 | 40 | /** 41 | * Return the user ID of the user that is logged in. 42 | * 43 | * @throws IllegalStateException Thrown when no user is logged in. 44 | */ 45 | @Override 46 | protected String getUserId() { 47 | return AppEngineServletUtils.getUserId(); 48 | } 49 | 50 | @Override 51 | protected HttpTransport newHttpTransportInstance() { 52 | return new UrlFetchTransport(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/AppEngineServletUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.auth; 16 | 17 | import com.google.api.client.util.Preconditions; 18 | import com.google.appengine.api.users.User; 19 | import com.google.appengine.api.users.UserService; 20 | import com.google.appengine.api.users.UserServiceFactory; 21 | 22 | /** 23 | * Utility methods that can be shared across App Engine specializations of the abstract auth 24 | * servlets. 25 | * 26 | * @author moshenko@google.com (Jacob Moshenko) 27 | * @since 1.4 28 | */ 29 | class AppEngineServletUtils { 30 | /** Private constructor to prevent instantiation. */ 31 | private AppEngineServletUtils() {} 32 | 33 | /** Return the user id for the currently logged in user. */ 34 | static final String getUserId() { 35 | UserService userService = UserServiceFactory.getUserService(); 36 | User loggedIn = userService.getCurrentUser(); 37 | Preconditions.checkState(loggedIn != null, "This servlet requires the user to be logged in."); 38 | return loggedIn.getUserId(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/oauth2/jakarta/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that help simplify the authorization flow on Google App Engine. This package 17 | * uses the {@code jakarta.servlet} namespace. 18 | * 19 | * @since 1.36.0 20 | */ 21 | package com.google.api.client.extensions.appengine.auth.oauth2.jakarta; 22 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/oauth2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that help simplify the authorization flow on Google App Engine. 17 | * 18 | * @since 1.7 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.extensions.appengine.auth.oauth2; 22 | -------------------------------------------------------------------------------- /google-oauth-client-appengine/src/main/java/com/google/api/client/extensions/appengine/auth/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * These servlets will allow an App Engine user to quickly get started with the auth object 18 | * interface from the main client. They will utilize the App Engine Datastore and Credentials to 19 | * manage credentials on behalf of users. 20 | * 21 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 22 | * {@link com.google.api.client.extensions.appengine.auth.oauth2}. 23 | * 24 | * @since 1.4 25 | * @author moshenko@google.com (Jacob Moshenko) 26 | */ 27 | @com.google.api.client.util.Beta 28 | package com.google.api.client.extensions.appengine.auth; 29 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/classpath-include: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/licenses/BSD-LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | Copyright (c) 2000-2006, www.hamcrest.org 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | Redistributions of source code must retain the above copyright notice, this list of 10 | conditions and the following disclaimer. Redistributions in binary form must reproduce 11 | the above copyright notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution. 13 | 14 | Neither the name of Hamcrest nor the names of its contributors may be used to endorse 15 | or promote products derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 26 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 | DAMAGE. 28 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/licenses/CDDL-LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-oauth-java-client/e771f812900b03c37f50c2ec6376998a178ee8c3/google-oauth-client-assembly/licenses/CDDL-LICENSE.txt -------------------------------------------------------------------------------- /google-oauth-client-assembly/licenses/xpp3_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Indiana University Extreme! Lab Software License 2 | 3 | Version 1.1.1 4 | 5 | Copyright (c) 2002 Extreme! Lab, Indiana University. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in 16 | the documentation and/or other materials provided with the distribution. 17 | 18 | 3. The end-user documentation included with the redistribution, if any, 19 | must include the following acknowledgment: 20 | 21 | "This product includes software developed by the Indiana University 22 | Extreme! Lab (http://www.extreme.indiana.edu/)." 23 | 24 | Alternately, this acknowledgment may appear in the software itself, 25 | if and wherever such third-party acknowledgments normally appear. 26 | 27 | 4. The names "Indiana Univeristy" and "Indiana Univeristy Extreme! Lab" 28 | must not be used to endorse or promote products derived from this 29 | software without prior written permission. For written permission, 30 | please contact http://www.extreme.indiana.edu/. 31 | 32 | 5. Products derived from this software may not use "Indiana Univeristy" 33 | name nor may "Indiana Univeristy" appear in their name, without prior 34 | written permission of the Indiana University. 35 | 36 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 37 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 38 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 39 | IN NO EVENT SHALL THE AUTHORS, COPYRIGHT HOLDERS OR ITS CONTRIBUTORS 40 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 41 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 42 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 43 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 44 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 45 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 46 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 47 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/proguard-google-oauth-client.txt: -------------------------------------------------------------------------------- 1 | # ProGuard Configuration file 2 | # 3 | # See http://proguard.sourceforge.net/index.html#manual/usage.html 4 | 5 | # Needed to keep generic types and @Key annotations accessed via reflection 6 | 7 | -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault 8 | 9 | -keepclassmembers class * { 10 | @com.google.api.client.util.Key ; 11 | } 12 | 13 | # Needed by google-http-client-android when linking against an older platform version 14 | 15 | -dontwarn com.google.api.client.extensions.android.** 16 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-http-client-android.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-android-${project.http.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-http-client-gson.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-gson-${project.http.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-http-client-jackson2.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-jackson2-${project.http.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-http-client-xml.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-xml-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-http-client.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-${project.http.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/google-oauth-client.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-oauth-client-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-assembly/properties/gson.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/gson-${project.gson.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-oauth-client-bom/README.md: -------------------------------------------------------------------------------- 1 | # Google OAuth Client Library Bill of Materials 2 | 3 | The `google-oauth-client-bom` module is a pom that can be used to import consistent 4 | versions of `google-oauth-client` components. 5 | 6 | To use it in Maven, add the following to your `pom.xml`: 7 | 8 | [//]: # ({x-version-update-start:google-oauth-client:released}) 9 | ```xml 10 | 11 | 12 | 13 | com.google.oauth-client 14 | google-oauth-client-bom 15 | 1.30.2 16 | pom 17 | import 18 | 19 | 20 | 21 | ``` 22 | [//]: # ({x-version-update-end}) 23 | 24 | ## License 25 | 26 | Apache 2.0 - See [LICENSE] for more information. 27 | 28 | [LICENSE]: https://github.com/googleapis/google-oauth-java-client/blob/master/LICENSE 29 | -------------------------------------------------------------------------------- /google-oauth-client-java6/resources/credentials.json: -------------------------------------------------------------------------------- 1 | {"credentials":{}} -------------------------------------------------------------------------------- /google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/AbstractPromptReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.java6.auth.oauth2; 16 | 17 | import java.util.Scanner; 18 | 19 | /** 20 | * OAuth 2.0 abstract verification code receiver that prompts user to paste the code copied from the 21 | * browser. 22 | * 23 | *

Implementation is thread-safe. 24 | * 25 | * @since 1.11 26 | * @author Yaniv Inbar 27 | */ 28 | public abstract class AbstractPromptReceiver implements VerificationCodeReceiver { 29 | 30 | @SuppressWarnings("resource") 31 | @Override 32 | public String waitForCode() { 33 | String code; 34 | do { 35 | System.out.print("Please enter code: "); 36 | code = new Scanner(System.in).nextLine(); 37 | } while (code.isEmpty()); 38 | return code; 39 | } 40 | 41 | @Override 42 | public void stop() {} 43 | } 44 | -------------------------------------------------------------------------------- /google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/VerificationCodeReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.java6.auth.oauth2; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * OAuth 2.0 verification code receiver. 21 | * 22 | *

Implementation should be thread-safe. 23 | * 24 | * @since 1.11 25 | * @author Yaniv Inbar 26 | */ 27 | public interface VerificationCodeReceiver { 28 | 29 | /** 30 | * Returns the redirect URI. 31 | * 32 | * @throws IOException 33 | */ 34 | String getRedirectUri() throws IOException; 35 | 36 | /** 37 | * Waits for a verification code. 38 | * 39 | * @throws IOException 40 | */ 41 | String waitForCode() throws IOException; 42 | 43 | /** 44 | * Releases any resources and stops any processes started. 45 | * 46 | * @throws IOException 47 | */ 48 | void stop() throws IOException; 49 | } 50 | -------------------------------------------------------------------------------- /google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that help simplify the authorization flow on Java 6. 17 | * 18 | * @since 1.11 19 | * @author Rafael Naufal 20 | */ 21 | package com.google.api.client.extensions.java6.auth.oauth2; 22 | -------------------------------------------------------------------------------- /google-oauth-client-jetty/resources/credentials.json: -------------------------------------------------------------------------------- 1 | {"credentials":{}} -------------------------------------------------------------------------------- /google-oauth-client-jetty/src/main/java/com/google/api/client/extensions/jetty/auth/oauth2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that simplify the authorization flow using an HTTP server. 17 | * 18 | * @since 1.11 19 | * @author Rafael Naufal 20 | */ 21 | package com.google.api.client.extensions.jetty.auth.oauth2; 22 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/auth/helpers/Credential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.auth.helpers; 16 | 17 | import com.google.api.client.http.HttpExecuteInterceptor; 18 | import com.google.api.client.http.HttpRequestInitializer; 19 | import com.google.api.client.http.HttpTransport; 20 | import com.google.api.client.http.HttpUnsuccessfulResponseHandler; 21 | import com.google.api.client.util.Beta; 22 | import javax.jdo.annotations.PersistenceCapable; 23 | 24 | /** 25 | * {@link Beta}
26 | * Implementations of this class will have all of the information necessary to create and install 27 | * the necessary handlers on an {@link HttpTransport} object to allow for a streamlined auth 28 | * experience. 29 | * 30 | *

Implementations of this interface should use the {@link PersistenceCapable} annotation to 31 | * allow credentials to be managed on behalf of the application. 32 | * 33 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 34 | * {@link com.google.api.client.auth.oauth2.Credential}. 35 | * 36 | * @author moshenko@google.com (Jacob Moshenko) 37 | * @since 1.4 38 | * @deprecated Use {@link com.google.api.client.auth.oauth2.Credential}. 39 | */ 40 | @Beta 41 | @Deprecated 42 | public interface Credential 43 | extends HttpRequestInitializer, HttpExecuteInterceptor, HttpUnsuccessfulResponseHandler { 44 | 45 | /** 46 | * Determine if the Credential is no longer valid, after being revoked for example. 47 | * 48 | * @since 1.5 49 | */ 50 | boolean isInvalid(); 51 | } 52 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/auth/helpers/ThreeLeggedFlow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.auth.helpers; 16 | 17 | import com.google.api.client.http.HttpTransport; 18 | import com.google.api.client.json.JsonFactory; 19 | import com.google.api.client.util.Beta; 20 | import java.io.IOException; 21 | import javax.jdo.PersistenceManager; 22 | import javax.jdo.annotations.PersistenceCapable; 23 | 24 | /** 25 | * {@link Beta}
26 | * Interface for auth flows that require a user authorization step through a web browser to obtain 27 | * an authorization code. 28 | * 29 | *

Implementations are required to be {@link PersistenceCapable} for storage in JDO compliant 30 | * datastores during user authorization step. 31 | * 32 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 33 | * {@link com.google.api.client.auth.oauth2.AuthorizationCodeFlow}. 34 | * 35 | * @author moshenko@google.com (Jacob Moshenko) 36 | * @since 1.4 37 | * @deprecated Use {@link com.google.api.client.auth.oauth2.AuthorizationCodeFlow}. 38 | */ 39 | @Beta 40 | @Deprecated 41 | public interface ThreeLeggedFlow { 42 | 43 | /** 44 | * After the object is created, the developer should use this method to interrogate it for the 45 | * authorization URL to which the user should be redirected to obtain permission. 46 | * 47 | * @return URL to which the user should be directed 48 | */ 49 | String getAuthorizationUrl(); 50 | 51 | /** Set {@link HttpTransport} instance for this three legged flow. */ 52 | void setHttpTransport(HttpTransport transport); 53 | 54 | /** Set {@link JsonFactory} instance for this three legged flow. */ 55 | void setJsonFactory(JsonFactory jsonFactory); 56 | 57 | /** 58 | * Convenience function that will load a credential based on the userId for which this flow was 59 | * instantiated. 60 | * 61 | * @param pm {@link PersistenceManager} instance which this flow should use to interact with the 62 | * data store. The caller must remember to call {@link PersistenceManager#close()} after this 63 | * method returns. 64 | * @return Fully initialized {@link Credential} object or {@code null} if none exists. 65 | */ 66 | Credential loadCredential(PersistenceManager pm); 67 | 68 | /** 69 | * After the user has authorized the request, the token or code obtained should be passed to this 70 | * complete function to allow us to exchange the code with the authentication server for a {@link 71 | * Credential}. 72 | * 73 | * @param authorizationCode Code or token obtained after the user grants permission 74 | * @return {@link Credential} object that is obtained from token server 75 | */ 76 | Credential complete(String authorizationCode) throws IOException; 77 | } 78 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/auth/helpers/oauth/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Implementation of auth objects to obtain and manage OAuth 1 credentials using the web server 18 | * flow. 19 | * 20 | * @since 1.5 21 | * @author moshenko@google.com (Jacob Moshenko) 22 | */ 23 | @com.google.api.client.util.Beta 24 | package com.google.api.client.extensions.auth.helpers.oauth; 25 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/auth/helpers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Auth object framework that will provide an interface to create easy to use, object-oriented 18 | * methods to obtain and manage auth credentials. 19 | * 20 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 21 | * {@code com.google.api.client.auth.oauth2}. 22 | * 23 | * @since 1.4 24 | * @author moshenko@google.com (Jacob Moshenko) 25 | */ 26 | @com.google.api.client.util.Beta 27 | package com.google.api.client.extensions.auth.helpers; 28 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/servlet/auth/oauth2/jakarta/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that help simplify the authorization flow in HTTP servlets in the {@code 17 | * jakarta.servlet} namespace. 18 | * 19 | * @since 1.36.0 20 | */ 21 | package com.google.api.client.extensions.servlet.auth.oauth2.jakarta; 22 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/servlet/auth/oauth2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * OAuth 2.0 utilities that help simplify the authorization flow in HTTP servlets. 17 | * 18 | * @since 1.7 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.extensions.servlet.auth.oauth2; 22 | -------------------------------------------------------------------------------- /google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/servlet/auth/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Servlets that can be completed by users to create and complete a web server auth flow to obtain a 18 | * credential. 19 | * 20 | *

Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use 21 | * {@link com.google.api.client.extensions.servlet.auth.oauth2}. 22 | * 23 | * @since 1.4 24 | * @author moshenko@google.com (Jacob Moshenko) 25 | */ 26 | @com.google.api.client.util.Beta 27 | package com.google.api.client.extensions.servlet.auth; 28 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/AbstractOAuthGetToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.http.GenericUrl; 18 | import com.google.api.client.http.HttpMethods; 19 | import com.google.api.client.http.HttpRequest; 20 | import com.google.api.client.http.HttpRequestFactory; 21 | import com.google.api.client.http.HttpResponse; 22 | import com.google.api.client.http.HttpTransport; 23 | import com.google.api.client.http.UrlEncodedParser; 24 | import com.google.api.client.util.Beta; 25 | import java.io.IOException; 26 | 27 | /** 28 | * {@link Beta}
29 | * Generic OAuth 1.0a URL to request a temporary or long-lived token from an authorization server. 30 | * 31 | * @since 1.0 32 | * @author Yaniv Inbar 33 | */ 34 | @Beta 35 | public abstract class AbstractOAuthGetToken extends GenericUrl { 36 | 37 | /** 38 | * HTTP transport required for executing request in {@link #execute()}. 39 | * 40 | * @since 1.3 41 | */ 42 | public HttpTransport transport; 43 | 44 | /** Required identifier portion of the client credentials (equivalent to a username). */ 45 | public String consumerKey; 46 | 47 | /** Required OAuth signature algorithm. */ 48 | public OAuthSigner signer; 49 | 50 | /** {@code true} for POST request or the default {@code false} for GET request. */ 51 | protected boolean usePost; 52 | 53 | /** @param authorizationServerUrl encoded authorization server URL */ 54 | protected AbstractOAuthGetToken(String authorizationServerUrl) { 55 | super(authorizationServerUrl); 56 | } 57 | 58 | /** 59 | * Executes the HTTP request for a temporary or long-lived token. 60 | * 61 | * @return OAuth credentials response object 62 | */ 63 | public final OAuthCredentialsResponse execute() throws IOException { 64 | HttpRequestFactory requestFactory = transport.createRequestFactory(); 65 | HttpRequest request = 66 | requestFactory.buildRequest(usePost ? HttpMethods.POST : HttpMethods.GET, this, null); 67 | createParameters().intercept(request); 68 | HttpResponse response = request.execute(); 69 | response.setContentLoggingLimit(0); 70 | OAuthCredentialsResponse oauthResponse = new OAuthCredentialsResponse(); 71 | UrlEncodedParser.parse(response.parseAsString(), oauthResponse); 72 | return oauthResponse; 73 | } 74 | 75 | /** 76 | * Returns a new instance of the OAuth authentication provider. Subclasses may override by calling 77 | * this super implementation and then adding OAuth parameters. 78 | */ 79 | public OAuthParameters createParameters() { 80 | OAuthParameters result = new OAuthParameters(); 81 | result.consumerKey = consumerKey; 82 | result.signer = signer; 83 | return result; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthAuthorizeTemporaryTokenUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.http.GenericUrl; 18 | import com.google.api.client.util.Beta; 19 | import com.google.api.client.util.Key; 20 | 21 | /** 22 | * {@link Beta}
23 | * OAuth 1.0a URL builder for an authorization web page to allow the end user to authorize the 24 | * temporary token. 25 | * 26 | *

The {@link #temporaryToken} should be set from the {@link OAuthCredentialsResponse#token} 27 | * returned by {@link OAuthGetTemporaryToken#execute()}. Use {@link #build()} to build the 28 | * authorization URL. If a {@link OAuthGetTemporaryToken#callback} was specified, after the end user 29 | * grants the authorization, the authorization server will redirect to that callback URL. To parse 30 | * the response, use {@link OAuthCallbackUrl}. 31 | * 32 | * @since 1.0 33 | * @author Yaniv Inbar 34 | */ 35 | @Beta 36 | public class OAuthAuthorizeTemporaryTokenUrl extends GenericUrl { 37 | 38 | /** 39 | * The temporary credentials token obtained from temporary credentials request in the 40 | * "oauth_token" parameter. It is found in the {@link OAuthCredentialsResponse#token} returned by 41 | * {@link OAuthGetTemporaryToken#execute()}. 42 | */ 43 | @Key("oauth_token") 44 | public String temporaryToken; 45 | 46 | /** @param encodedUserAuthorizationUrl encoded user authorization URL */ 47 | public OAuthAuthorizeTemporaryTokenUrl(String encodedUserAuthorizationUrl) { 48 | super(encodedUserAuthorizationUrl); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthCallbackUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.http.GenericUrl; 18 | import com.google.api.client.util.Beta; 19 | import com.google.api.client.util.Key; 20 | 21 | /** 22 | * {@link Beta}
23 | * Generic URL that parses the callback URL after a temporary token has been authorized by the end 24 | * user. 25 | * 26 | *

The {@link #verifier} is required in order to exchange the authorized temporary token for a 27 | * long-lived access token in {@link OAuthGetAccessToken#verifier}. 28 | * 29 | * @since 1.0 30 | * @author Yaniv Inbar 31 | */ 32 | @Beta 33 | public class OAuthCallbackUrl extends GenericUrl { 34 | 35 | /** The temporary credentials identifier received from the client. */ 36 | @Key("oauth_token") 37 | public String token; 38 | 39 | /** The verification code. */ 40 | @Key("oauth_verifier") 41 | public String verifier; 42 | 43 | public OAuthCallbackUrl(String encodedUrl) { 44 | super(encodedUrl); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthCredentialsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.Key; 19 | 20 | /** 21 | * {@link Beta}
22 | * Data to parse a success response to a request for temporary or token credentials. 23 | * 24 | * @since 1.0 25 | * @author Yaniv Inbar 26 | */ 27 | @Beta 28 | public final class OAuthCredentialsResponse { 29 | 30 | /** Credentials token. */ 31 | @Key("oauth_token") 32 | public String token; 33 | 34 | /** 35 | * Credentials shared-secret for use with {@code "HMAC-SHA1"} signature algorithm. Used for {@link 36 | * OAuthHmacSigner#tokenSharedSecret}. 37 | */ 38 | @Key("oauth_token_secret") 39 | public String tokenSecret; 40 | 41 | /** 42 | * {@code "true"} for temporary credentials request or {@code null} for a token credentials 43 | * request. The parameter is used to differentiate from previous versions of the protocol. 44 | */ 45 | @Key("oauth_callback_confirmed") 46 | public Boolean callbackConfirmed; 47 | } 48 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthGetAccessToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** 20 | * {@link Beta}
21 | * Generic OAuth 1.0a URL to request to exchange the temporary credentials token (or "request 22 | * token") for a long-lived credentials token (or "access token") from an authorization server. 23 | * 24 | *

Use {@link #execute()} to execute the request. The long-lived access token acquired with this 25 | * request is found in {@link OAuthCredentialsResponse#token} . This token must be stored. It may 26 | * then be used to authorize HTTP requests to protected resources by using {@link OAuthParameters}. 27 | * 28 | * @since 1.0 29 | * @author Yaniv Inbar 30 | */ 31 | @Beta 32 | public class OAuthGetAccessToken extends AbstractOAuthGetToken { 33 | 34 | /** 35 | * Required temporary token. It is retrieved from the {@link OAuthCredentialsResponse#token} 36 | * returned from {@link OAuthGetTemporaryToken#execute()}. 37 | */ 38 | public String temporaryToken; 39 | 40 | /** 41 | * Required verifier code received from the server when the temporary token was authorized. It is 42 | * retrieved from {@link OAuthCallbackUrl#verifier}. 43 | */ 44 | public String verifier; 45 | 46 | /** @param authorizationServerUrl encoded authorization server URL */ 47 | public OAuthGetAccessToken(String authorizationServerUrl) { 48 | super(authorizationServerUrl); 49 | } 50 | 51 | @Override 52 | public OAuthParameters createParameters() { 53 | OAuthParameters result = super.createParameters(); 54 | result.token = temporaryToken; 55 | result.verifier = verifier; 56 | return result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthGetTemporaryToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** 20 | * {@link Beta}
21 | * Generic OAuth 1.0a URL to request a temporary credentials token (or "request token") from an 22 | * authorization server. 23 | * 24 | *

Use {@link #execute()} to execute the request. The temporary token acquired with this request 25 | * is found in {@link OAuthCredentialsResponse#token}. This temporary token is used in {@link 26 | * OAuthAuthorizeTemporaryTokenUrl#temporaryToken} to direct the end user to an authorization page 27 | * to allow the end user to authorize the temporary token. 28 | * 29 | * @since 1.0 30 | * @author Yaniv Inbar 31 | */ 32 | @Beta 33 | public class OAuthGetTemporaryToken extends AbstractOAuthGetToken { 34 | 35 | /** 36 | * Optional absolute URI back to which the server will redirect the resource owner when the 37 | * Resource Owner Authorization step is completed or {@code null} for none. 38 | */ 39 | public String callback; 40 | 41 | /** @param authorizationServerUrl encoded authorization server URL */ 42 | public OAuthGetTemporaryToken(String authorizationServerUrl) { 43 | super(authorizationServerUrl); 44 | } 45 | 46 | @Override 47 | public OAuthParameters createParameters() { 48 | OAuthParameters result = super.createParameters(); 49 | result.callback = callback; 50 | return result; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthHmacSha256Signer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.StringUtils; 18 | import com.google.common.io.BaseEncoding; 19 | import java.security.GeneralSecurityException; 20 | import javax.crypto.Mac; 21 | import javax.crypto.SecretKey; 22 | import javax.crypto.spec.SecretKeySpec; 23 | 24 | /** OAuth {@code "HMAC-SHA256"} signature method. */ 25 | public final class OAuthHmacSha256Signer implements OAuthSigner { 26 | 27 | /** Client secret */ 28 | private final String clientSharedSecret; 29 | 30 | /** Token secret */ 31 | private String tokenSharedSecret; 32 | 33 | public void setTokenSecret(String tokenSecret) { 34 | tokenSharedSecret = tokenSecret; 35 | } 36 | 37 | public OAuthHmacSha256Signer(String clientSecret) { 38 | this.clientSharedSecret = clientSecret; 39 | } 40 | 41 | @Override 42 | public String getSignatureMethod() { 43 | return "HMAC-SHA256"; 44 | } 45 | 46 | @Override 47 | public String computeSignature(String signatureBaseString) throws GeneralSecurityException { 48 | // compute key 49 | StringBuilder keyBuffer = new StringBuilder(); 50 | if (clientSharedSecret != null) { 51 | keyBuffer.append(OAuthParameters.escape(clientSharedSecret)); 52 | } 53 | keyBuffer.append('&'); 54 | if (tokenSharedSecret != null) { 55 | keyBuffer.append(OAuthParameters.escape(tokenSharedSecret)); 56 | } 57 | String key = keyBuffer.toString(); 58 | // sign 59 | SecretKey secretKey = new SecretKeySpec(StringUtils.getBytesUtf8(key), "HmacSHA256"); 60 | Mac mac = Mac.getInstance("HmacSHA256"); 61 | mac.init(secretKey); 62 | return BaseEncoding.base64().encode(mac.doFinal(StringUtils.getBytesUtf8(signatureBaseString))); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthHmacSigner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Base64; 18 | import com.google.api.client.util.Beta; 19 | import com.google.api.client.util.StringUtils; 20 | import java.security.GeneralSecurityException; 21 | import javax.crypto.Mac; 22 | import javax.crypto.SecretKey; 23 | import javax.crypto.spec.SecretKeySpec; 24 | 25 | /** 26 | * {@link Beta}
27 | * OAuth {@code "HMAC-SHA1"} signature method. 28 | * 29 | * @since 1.0 30 | * @author Yaniv Inbar 31 | */ 32 | @Beta 33 | public final class OAuthHmacSigner implements OAuthSigner { 34 | 35 | /** Client-shared secret or {@code null} for none. */ 36 | public String clientSharedSecret; 37 | 38 | /** Token-shared secret or {@code null} for none. */ 39 | public String tokenSharedSecret; 40 | 41 | public String getSignatureMethod() { 42 | return "HMAC-SHA1"; 43 | } 44 | 45 | public String computeSignature(String signatureBaseString) throws GeneralSecurityException { 46 | // compute key 47 | StringBuilder keyBuf = new StringBuilder(); 48 | String clientSharedSecret = this.clientSharedSecret; 49 | if (clientSharedSecret != null) { 50 | keyBuf.append(OAuthParameters.escape(clientSharedSecret)); 51 | } 52 | keyBuf.append('&'); 53 | String tokenSharedSecret = this.tokenSharedSecret; 54 | if (tokenSharedSecret != null) { 55 | keyBuf.append(OAuthParameters.escape(tokenSharedSecret)); 56 | } 57 | String key = keyBuf.toString(); 58 | // sign 59 | SecretKey secretKey = new SecretKeySpec(StringUtils.getBytesUtf8(key), "HmacSHA1"); 60 | Mac mac = Mac.getInstance("HmacSHA1"); 61 | mac.init(secretKey); 62 | return Base64.encodeBase64String(mac.doFinal(StringUtils.getBytesUtf8(signatureBaseString))); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthRsaSigner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Base64; 18 | import com.google.api.client.util.Beta; 19 | import com.google.api.client.util.SecurityUtils; 20 | import com.google.api.client.util.StringUtils; 21 | import java.security.GeneralSecurityException; 22 | import java.security.PrivateKey; 23 | import java.security.Signature; 24 | 25 | /** 26 | * {@link Beta}
27 | * OAuth {@code "RSA-SHA1"} signature method. 28 | * 29 | *

The private key may be loaded using the utilities in {@link SecurityUtils}. 30 | * 31 | * @since 1.0 32 | * @author Yaniv Inbar 33 | */ 34 | @Beta 35 | public final class OAuthRsaSigner implements OAuthSigner { 36 | 37 | /** Private key. */ 38 | public PrivateKey privateKey; 39 | 40 | public String getSignatureMethod() { 41 | return "RSA-SHA1"; 42 | } 43 | 44 | public String computeSignature(String signatureBaseString) throws GeneralSecurityException { 45 | Signature signer = SecurityUtils.getSha1WithRsaSignatureAlgorithm(); 46 | byte[] data = StringUtils.getBytesUtf8(signatureBaseString); 47 | return Base64.encodeBase64String(SecurityUtils.sign(signer, privateKey, data)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth/OAuthSigner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Beta; 18 | import java.security.GeneralSecurityException; 19 | 20 | /** 21 | * {@link Beta}
22 | * OAuth signature method. 23 | * 24 | * @since 1.0 25 | * @author Yaniv Inbar 26 | */ 27 | @Beta 28 | public interface OAuthSigner { 29 | 30 | /** Returns the signature method. */ 31 | String getSignatureMethod(); 32 | 33 | /** 34 | * Returns the signature computed from the given signature base string. 35 | * 36 | * @throws GeneralSecurityException general security exception 37 | */ 38 | String computeSignature(String signatureBaseString) throws GeneralSecurityException; 39 | } 40 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/BrowserClientRequestUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import java.util.Collection; 18 | import java.util.Collections; 19 | 20 | /** 21 | * OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the 22 | * application to access their protected resources and that returns the access token to a browser 23 | * client using a scripting language such as JavaScript, as specified in Implicit Grant. 25 | * 26 | *

The default for {@link #getResponseTypes()} is {@code "token"}. 27 | * 28 | *

Sample usage for a web application: 29 | * 30 | *

{@code
31 |  * public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
32 |  * String url = new BrowserClientRequestUrl(
33 |  * "https://server.example.com/authorize", "s6BhdRkqt3").setState("xyz")
34 |  * .setRedirectUri("https://client.example.com/cb").build();
35 |  * response.sendRedirect(url);
36 |  * }
37 |  * }
38 | * 39 | *

Implementation is not thread-safe. 40 | * 41 | * @since 1.7 42 | * @author Yaniv Inbar 43 | */ 44 | public class BrowserClientRequestUrl extends AuthorizationRequestUrl { 45 | 46 | /** 47 | * @param encodedAuthorizationServerUrl encoded authorization server URL 48 | * @param clientId client identifier 49 | */ 50 | public BrowserClientRequestUrl(String encodedAuthorizationServerUrl, String clientId) { 51 | super(encodedAuthorizationServerUrl, clientId, Collections.singleton("token")); 52 | } 53 | 54 | @Override 55 | public BrowserClientRequestUrl setResponseTypes(Collection responseTypes) { 56 | return (BrowserClientRequestUrl) super.setResponseTypes(responseTypes); 57 | } 58 | 59 | @Override 60 | public BrowserClientRequestUrl setRedirectUri(String redirectUri) { 61 | return (BrowserClientRequestUrl) super.setRedirectUri(redirectUri); 62 | } 63 | 64 | @Override 65 | public BrowserClientRequestUrl setScopes(Collection scopes) { 66 | return (BrowserClientRequestUrl) super.setScopes(scopes); 67 | } 68 | 69 | @Override 70 | public BrowserClientRequestUrl setClientId(String clientId) { 71 | return (BrowserClientRequestUrl) super.setClientId(clientId); 72 | } 73 | 74 | @Override 75 | public BrowserClientRequestUrl setState(String state) { 76 | return (BrowserClientRequestUrl) super.setState(state); 77 | } 78 | 79 | @Override 80 | public BrowserClientRequestUrl set(String fieldName, Object value) { 81 | return (BrowserClientRequestUrl) super.set(fieldName, value); 82 | } 83 | 84 | @Override 85 | public BrowserClientRequestUrl clone() { 86 | return (BrowserClientRequestUrl) super.clone(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/CredentialRefreshListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Listener for refresh token results. 21 | * 22 | *

These methods are called from {@link Credential#refreshToken()} after a response has been 23 | * received from refreshing the token. {@link #onTokenResponse} is called on a successful HTTP 24 | * response, and {@link #onTokenErrorResponse} is called on an error HTTP response. 25 | * 26 | * @since 1.7 27 | * @author Yaniv Inbar 28 | */ 29 | public interface CredentialRefreshListener { 30 | 31 | /** 32 | * Notifies of a successful token response from {@link Credential#refreshToken()}. 33 | * 34 | *

Typical use is to provide functionality like persisting the access token in a data store. 35 | * Implementations can assume proper thread synchronization is already taken care of inside {@link 36 | * Credential#refreshToken()}. Implementations can also assume that {@link 37 | * Credential#setAccessToken}, {@link Credential#setRefreshToken}, and {@link 38 | * Credential#setExpiresInSeconds} have already been called previously with the information from 39 | * the {@link TokenResponse}. 40 | * 41 | * @param credential credential on which the token refresh applied 42 | * @param tokenResponse token response 43 | */ 44 | void onTokenResponse(Credential credential, TokenResponse tokenResponse) throws IOException; 45 | 46 | /** 47 | * Notifies of an error token response from {@link Credential#refreshToken()}. 48 | * 49 | *

Typical use is to provide functionality like removing persistence of the access token from 50 | * the data store. Implementations can assume proper thread synchronization is already taken care 51 | * of inside {@link Credential#refreshToken()}. Implementations can also assume that {@link 52 | * Credential#setAccessToken}, and {@link Credential#setExpiresInSeconds} have already been called 53 | * previously with {@code null} to clear their values. 54 | * 55 | * @param credential credential on which the token refresh applied 56 | * @param tokenErrorResponse token error response or {@code null} for none supplied 57 | */ 58 | void onTokenErrorResponse(Credential credential, TokenErrorResponse tokenErrorResponse) 59 | throws IOException; 60 | } 61 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/CredentialStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.store.DataStoreFactory; 19 | import java.io.IOException; 20 | 21 | /** 22 | * {@link Beta}
23 | * OAuth 2.0 credential persistence store interface to provide a fully pluggable storage mechanism. 24 | * 25 | *

The user ID should be used as the primary key for storage, and the rest of the data consists 26 | * of the {@link Credential#getAccessToken access token}, {@link Credential#getRefreshToken refresh 27 | * token}, and {@link Credential#getExpirationTimeMilliseconds expiration time}. 28 | * 29 | *

Implementations should be thread safe. 30 | * 31 | * @since 1.7 32 | * @author Yaniv Inbar 33 | * @deprecated (to be removed in the future) Use {@link DataStoreFactory} with {@link 34 | * StoredCredential} instead. 35 | */ 36 | @Deprecated 37 | @Beta 38 | public interface CredentialStore { 39 | 40 | /** 41 | * Loads the credential for the given user ID. 42 | * 43 | * @param userId user ID whose credential needs to be loaded 44 | * @param credential credential whose {@link Credential#setAccessToken access token}, {@link 45 | * Credential#setRefreshToken refresh token}, and {@link 46 | * Credential#setExpirationTimeMilliseconds expiration time} need to be set if the credential 47 | * already exists in storage 48 | * @return {@code true} if the credential has been successfully found and loaded or {@code false} 49 | * otherwise 50 | */ 51 | boolean load(String userId, Credential credential) throws IOException; 52 | 53 | /** 54 | * Stores the credential of the given user ID. 55 | * 56 | * @param userId user ID whose credential needs to be stored 57 | * @param credential credential whose {@link Credential#getAccessToken access token}, {@link 58 | * Credential#getRefreshToken refresh token}, and {@link 59 | * Credential#getExpirationTimeMilliseconds expiration time} need to be stored 60 | */ 61 | void store(String userId, Credential credential) throws IOException; 62 | 63 | /** 64 | * Deletes the credential of the given user ID. 65 | * 66 | * @param userId user ID whose credential needs to be deleted 67 | * @param credential credential to be deleted 68 | */ 69 | void delete(String userId, Credential credential) throws IOException; 70 | } 71 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/CredentialStoreRefreshListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.Preconditions; 19 | import java.io.IOException; 20 | 21 | /** 22 | * {@link Beta}
23 | * Thread-safe OAuth 2.0 credential refresh listener that stores the refresh token response in the 24 | * credential store. 25 | * 26 | *

It needs to be added as a refresh listener using {@link 27 | * Credential.Builder#addRefreshListener}. 28 | * 29 | * @since 1.7 30 | * @author Yaniv Inbar 31 | * @deprecated (to be removed in the future) Use {@link DataStoreCredentialRefreshListener} instead. 32 | */ 33 | @Deprecated 34 | @Beta 35 | public final class CredentialStoreRefreshListener implements CredentialRefreshListener { 36 | 37 | /** Credential store. */ 38 | private final CredentialStore credentialStore; 39 | 40 | /** User ID whose credential is to be updated. */ 41 | private final String userId; 42 | 43 | /** 44 | * @param userId user ID whose credential is to be updated 45 | * @param credentialStore credential store 46 | */ 47 | public CredentialStoreRefreshListener(String userId, CredentialStore credentialStore) { 48 | this.userId = Preconditions.checkNotNull(userId); 49 | this.credentialStore = Preconditions.checkNotNull(credentialStore); 50 | } 51 | 52 | public void onTokenResponse(Credential credential, TokenResponse tokenResponse) 53 | throws IOException { 54 | makePersistent(credential); 55 | } 56 | 57 | public void onTokenErrorResponse(Credential credential, TokenErrorResponse tokenErrorResponse) 58 | throws IOException { 59 | makePersistent(credential); 60 | } 61 | 62 | /** Returns the credential store. */ 63 | public CredentialStore getCredentialStore() { 64 | return credentialStore; 65 | } 66 | 67 | /** Stores the updated credential in the credential store. */ 68 | public void makePersistent(Credential credential) throws IOException { 69 | credentialStore.store(userId, credential); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Implementation of the OAuth 2.0 Authorization 17 | * Framework. 18 | * 19 | *

Before using this library, you will typically need to register your application with the 20 | * authorization server to receive a client ID and client secret. See Client Registration. 22 | * 23 | *

These are the typical steps of the web server flow based on an authorization code, as 24 | * specified in Authorization Code 25 | * Grant: 26 | * 27 | *

    28 | *
  • Redirect the end user in the browser to the authorization page using {@link 29 | * com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl} to grant your application 30 | * access to the end user's protected data. 31 | *
  • Process the authorization response using {@link 32 | * com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl} to parse the authorization 33 | * code. 34 | *
  • Request an access token and possibly a refresh token using {@link 35 | * com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest}. 36 | *
  • Access protected resources using {@link com.google.api.client.auth.oauth2.Credential}. 37 | * Expired access tokens will automatically be refreshed using the refresh token (if 38 | * applicable). 39 | *
40 | * 41 | *

These are the typical steps of the the browser-based client flow specified in Implicit Grant: 43 | * 44 | *

    45 | *
  • Redirect the end user in the browser to the authorization page using {@link 46 | * com.google.api.client.auth.oauth2.BrowserClientRequestUrl} to grant your browser 47 | * application access to the end user's protected data. 48 | *
  • Use a JavaScript application to process the access token found in the URL fragment at the 49 | * redirect URI registered with the authorization server. 50 | *
51 | * 52 | * @since 1.7 53 | * @author Yaniv Inbar 54 | */ 55 | package com.google.api.client.auth.oauth2; 56 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package com.google.api.client.auth.openidconnect; 33 | 34 | class Environment { 35 | public String getVariable(String name) { 36 | return System.getenv(name); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/HttpTransportFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package com.google.api.client.auth.openidconnect; 33 | 34 | import com.google.api.client.http.HttpTransport; 35 | 36 | /** 37 | * A base interface for all {@link HttpTransport} factories. 38 | * 39 | *

Implementation must provide a public no-arg constructor. Loading of a factory implementation 40 | * is done via {@link java.util.ServiceLoader}. 41 | */ 42 | public interface HttpTransportFactory { 43 | 44 | /** 45 | * Creates a {@code HttpTransport} instance. 46 | * 47 | * @return The HttpTransport instance. 48 | */ 49 | HttpTransport create(); 50 | } 51 | -------------------------------------------------------------------------------- /google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * OpenID Connect. 18 | * 19 | * @since 1.7 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.auth.openidconnect; 24 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth/OAuthHmacSha256SignerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import java.security.GeneralSecurityException; 20 | import org.junit.Test; 21 | 22 | /** Tests {@link OAuthHmacSha256Signer}. */ 23 | public class OAuthHmacSha256SignerTest { 24 | 25 | @Test 26 | public void testComputeSignatureWithNullSecrets() throws GeneralSecurityException { 27 | OAuthHmacSha256Signer signer = new OAuthHmacSha256Signer(null); 28 | String expectedSignature = "l/Es58FI4BtBciSH9XtY/5jXFee70v7/rPiQgEpvv00="; 29 | assertEquals(expectedSignature, signer.computeSignature("baseString")); 30 | } 31 | 32 | @Test 33 | public void testComputeSignatureWithNullClientSecret() throws GeneralSecurityException { 34 | OAuthHmacSha256Signer signer = new OAuthHmacSha256Signer(null); 35 | signer.setTokenSecret("tokenSecret"); 36 | String expectedSignature = "PgNWY2qQ53qvk3WySct/f037/usxMGpNDjmJeISmgCM="; 37 | assertEquals(expectedSignature, signer.computeSignature("baseString")); 38 | } 39 | 40 | @Test 41 | public void testComputeSignatureWithNullTokenSecret() throws GeneralSecurityException { 42 | OAuthHmacSha256Signer signer = new OAuthHmacSha256Signer("clientSecret"); 43 | String expectedSignature = "cNrT2sqgyQ+dd7rbAhYBFBk8o82/yZyZkavqsfMDqpo="; 44 | assertEquals(expectedSignature, signer.computeSignature("baseString")); 45 | } 46 | 47 | @Test 48 | public void testComputeSignature() throws GeneralSecurityException { 49 | OAuthHmacSha256Signer signer = new OAuthHmacSha256Signer("clientSecret"); 50 | signer.setTokenSecret("tokenSecret"); 51 | String expectedSignature = "sfnrBcfwccOs2mpc60VQ5zXx5ReP/46lgUcBhU2a4PM="; 52 | assertEquals(expectedSignature, signer.computeSignature("baseString")); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth/OAuthHmacSignerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import java.security.GeneralSecurityException; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link OAuthHmacSigner}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class OAuthHmacSignerTest extends TestCase { 26 | 27 | private static final String EXPECTED_SIGNATURE = "0anl6O7gtZfslLZ5j3QoTwd0uPY="; 28 | 29 | public void testComputeSignature() throws GeneralSecurityException { 30 | OAuthHmacSigner signer = new OAuthHmacSigner(); 31 | signer.clientSharedSecret = "abc"; 32 | signer.tokenSharedSecret = "def"; 33 | assertEquals(EXPECTED_SIGNATURE, signer.computeSignature("foo")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth/OAuthRsaSignerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth; 16 | 17 | import com.google.api.client.util.Base64; 18 | import com.google.api.client.util.SecurityUtils; 19 | import com.google.api.client.util.StringUtils; 20 | import java.security.GeneralSecurityException; 21 | import java.security.KeyPairGenerator; 22 | import junit.framework.TestCase; 23 | 24 | /** 25 | * Tests {@link OAuthRsaSigner}. 26 | * 27 | * @author Yaniv Inbar 28 | */ 29 | public class OAuthRsaSignerTest extends TestCase { 30 | 31 | public void testComputeSignature() throws GeneralSecurityException { 32 | OAuthRsaSigner signer = new OAuthRsaSigner(); 33 | KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); 34 | keyPairGenerator.initialize(1024); 35 | signer.privateKey = keyPairGenerator.genKeyPair().getPrivate(); 36 | byte[] expected = 37 | SecurityUtils.sign( 38 | SecurityUtils.getSha1WithRsaSignatureAlgorithm(), 39 | signer.privateKey, 40 | StringUtils.getBytesUtf8("foo")); 41 | assertEquals(Base64.encodeBase64String(expected), signer.computeSignature("foo")); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/AuthorizationCodeRequestUrlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import java.util.Arrays; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link AuthorizationCodeRequestUrl}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class AuthorizationCodeRequestUrlTest extends TestCase { 26 | 27 | private static final String EXPECTED = 28 | "https://server.example.com/authorize?client_id=s6BhdRkqt3&" 29 | + "redirect_uri=https://client.example.com/rd&response_type=code" 30 | + "&scope=a%20b%20c&state=xyz"; 31 | 32 | public AuthorizationCodeRequestUrlTest(String name) { 33 | super(name); 34 | } 35 | 36 | public void testBuild() { 37 | AuthorizationRequestUrl url = 38 | new AuthorizationCodeRequestUrl("https://server.example.com/authorize", "s6BhdRkqt3") 39 | .setState("xyz") 40 | .setRedirectUri("https://client.example.com/rd") 41 | .setScopes(Arrays.asList("a", "b", "c")); 42 | assertEquals(EXPECTED, url.build()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/AuthorizationCodeResponseUrlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import junit.framework.TestCase; 18 | 19 | /** 20 | * Tests {@link AuthorizationCodeResponseUrl}. 21 | * 22 | * @author Yaniv Inbar 23 | */ 24 | public class AuthorizationCodeResponseUrlTest extends TestCase { 25 | 26 | public void testConstructor() { 27 | try { 28 | new AuthorizationCodeResponseUrl("http://example.com"); 29 | fail("expected " + IllegalArgumentException.class); 30 | } catch (IllegalArgumentException e) { 31 | // expected 32 | } 33 | AuthorizationCodeResponseUrl response = 34 | new AuthorizationCodeResponseUrl( 35 | "https://client.example.com/rd?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz"); 36 | assertEquals("SplxlOBeZQQYbYS6WxSbIA", response.getCode()); 37 | assertEquals("xyz", response.getState()); 38 | response = 39 | new AuthorizationCodeResponseUrl( 40 | "https://client.example.com/rd?error=access_denied&state=xyz"); 41 | assertEquals("access_denied", response.getError()); 42 | assertEquals("xyz", response.getState()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/AuthorizationCodeTokenRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.auth.openidconnect.IdTokenResponse; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link AuthorizationCodeTokenRequest}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class AuthorizationCodeTokenRequestTest extends TestCase { 26 | 27 | private static final String CODE = "i1WsRn1uB1"; 28 | private static final String REDIRECT_URI = "https://client.example.com/rd"; 29 | 30 | public void testConstructor() { 31 | check( 32 | new AuthorizationCodeTokenRequest( 33 | TokenRequestTest.TRANSPORT, 34 | TokenRequestTest.JSON_FACTORY, 35 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 36 | CODE) 37 | .setRedirectUri(REDIRECT_URI)); 38 | } 39 | 40 | private void check(AuthorizationCodeTokenRequest request) { 41 | TokenRequestTest.check(request, "authorization_code"); 42 | assertEquals(CODE, request.getCode()); 43 | assertEquals(REDIRECT_URI, request.getRedirectUri()); 44 | } 45 | 46 | public void testSetResponseClass() { 47 | AuthorizationCodeTokenRequest request = 48 | new AuthorizationCodeTokenRequest( 49 | TokenRequestTest.TRANSPORT, 50 | TokenRequestTest.JSON_FACTORY, 51 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 52 | CODE) 53 | .setResponseClass(IdTokenResponse.class); 54 | assertEquals(IdTokenResponse.class, request.getResponseClass()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/AuthorizationRequestUrlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import java.util.Arrays; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link AuthorizationRequestUrl}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class AuthorizationRequestUrlTest extends TestCase { 26 | 27 | private static final String EXPECTED = 28 | "https://server.example.com/authorize?client_id=s6BhdRkqt3&" 29 | + "redirect_uri=https://client.example.com/rd&response_type=code%20token" 30 | + "&scope=a%20b%20c&state=xyz"; 31 | 32 | public AuthorizationRequestUrlTest(String name) { 33 | super(name); 34 | } 35 | 36 | public void testBuild() { 37 | AuthorizationRequestUrl url = 38 | new AuthorizationRequestUrl( 39 | "https://server.example.com/authorize", 40 | "s6BhdRkqt3", 41 | Arrays.asList("code", "token")) 42 | .setState("xyz") 43 | .setRedirectUri("https://client.example.com/rd") 44 | .setScopes(Arrays.asList("a", "b", "c")); 45 | assertEquals(EXPECTED, url.build()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/BrowserClientRequestUrlTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import java.util.Arrays; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link BrowserClientRequestUrl}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class BrowserClientRequestUrlTest extends TestCase { 26 | 27 | private static final String EXPECTED = 28 | "https://server.example.com/authorize?client_id=s6BhdRkqt3&" 29 | + "redirect_uri=https://client.example.com/cb&response_type=token" 30 | + "&scope=a%20b%20c&state=xyz"; 31 | 32 | public void testBuild() { 33 | BrowserClientRequestUrl url = 34 | new BrowserClientRequestUrl("https://server.example.com/authorize", "s6BhdRkqt3") 35 | .setState("xyz") 36 | .setRedirectUri("https://client.example.com/cb") 37 | .setScopes(Arrays.asList("a", "b", "c")); 38 | assertEquals(EXPECTED, url.build()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/ClientCredentialsTokenRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.auth.openidconnect.IdTokenResponse; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link ClientCredentialsTokenRequest}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class ClientCredentialsTokenRequestTest extends TestCase { 26 | 27 | public void testConstructor() { 28 | check( 29 | new ClientCredentialsTokenRequest( 30 | TokenRequestTest.TRANSPORT, 31 | TokenRequestTest.JSON_FACTORY, 32 | TokenRequestTest.AUTHORIZATION_SERVER_URL)); 33 | } 34 | 35 | private void check(ClientCredentialsTokenRequest request) { 36 | TokenRequestTest.check(request, "client_credentials"); 37 | } 38 | 39 | public void testSetResponseClass() { 40 | ClientCredentialsTokenRequest request = 41 | new ClientCredentialsTokenRequest( 42 | TokenRequestTest.TRANSPORT, 43 | TokenRequestTest.JSON_FACTORY, 44 | TokenRequestTest.AUTHORIZATION_SERVER_URL) 45 | .setResponseClass(IdTokenResponse.class); 46 | assertEquals(IdTokenResponse.class, request.getResponseClass()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/ClientParametersAuthenticationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.http.HttpRequest; 18 | import com.google.api.client.http.UrlEncodedContent; 19 | import com.google.api.client.testing.http.HttpTesting; 20 | import com.google.api.client.testing.http.MockHttpTransport; 21 | import java.util.Map; 22 | import junit.framework.TestCase; 23 | 24 | /** 25 | * Tests {@link ClientParametersAuthentication}. 26 | * 27 | * @author Yaniv Inbar 28 | */ 29 | public class ClientParametersAuthenticationTest extends TestCase { 30 | 31 | private static final String CLIENT_ID = "s6BhdRkqt3"; 32 | private static final String CLIENT_SECRET = "7Fjfp0ZBr1KtDRbnfVdmIw"; 33 | 34 | public void test() throws Exception { 35 | HttpRequest request = 36 | new MockHttpTransport() 37 | .createRequestFactory() 38 | .buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); 39 | ClientParametersAuthentication auth = 40 | new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET); 41 | assertEquals(CLIENT_ID, auth.getClientId()); 42 | assertEquals(CLIENT_SECRET, auth.getClientSecret()); 43 | auth.intercept(request); 44 | UrlEncodedContent content = (UrlEncodedContent) request.getContent(); 45 | @SuppressWarnings("unchecked") 46 | Map data = (Map) content.getData(); 47 | assertEquals(CLIENT_ID, data.get("client_id")); 48 | assertEquals(CLIENT_SECRET, data.get("client_secret")); 49 | } 50 | 51 | public void test_noSecret() throws Exception { 52 | HttpRequest request = 53 | new MockHttpTransport() 54 | .createRequestFactory() 55 | .buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); 56 | ClientParametersAuthentication auth = new ClientParametersAuthentication(CLIENT_ID, null); 57 | assertEquals(CLIENT_ID, auth.getClientId()); 58 | assertNull(auth.getClientSecret()); 59 | auth.intercept(request); 60 | UrlEncodedContent content = (UrlEncodedContent) request.getContent(); 61 | @SuppressWarnings("unchecked") 62 | Map data = (Map) content.getData(); 63 | assertEquals(CLIENT_ID, data.get("client_id")); 64 | assertNull(data.get("client_secret")); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/CustomTokenResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.json.JsonFactory; 18 | import com.google.api.client.json.gson.GsonFactory; 19 | import com.google.api.client.util.Key; 20 | import junit.framework.TestCase; 21 | 22 | /** 23 | * Tests {@link TokenResponse}. 24 | * 25 | * @author Jeff Ching 26 | */ 27 | public class CustomTokenResponseTest extends TestCase { 28 | 29 | private static final String JSON = 30 | "{\"access_token\":\"2YotnFZFEjr1zCsicMWpAA\"," 31 | + "\"token_type\":\"example\",\"expires_in\":\"3600\"," 32 | + "\"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\"," 33 | + "\"example_parameter\":\"example_value\"}"; 34 | 35 | public static class StringExpiresTokenResponse extends TokenResponse { 36 | 37 | @Key("expires_in") 38 | private String expiresInSecondsString; 39 | 40 | public Long getExpiresInSeconds() { 41 | return Long.parseLong(expiresInSecondsString); 42 | } 43 | 44 | public StringExpiresTokenResponse setExpiresInSeconds(Long expiresInSeconds) { 45 | expiresInSecondsString = expiresInSeconds.toString(); 46 | return this; 47 | } 48 | } 49 | 50 | public void testStringExpires() throws Exception { 51 | JsonFactory jsonFactory = new GsonFactory(); 52 | TokenResponse response = jsonFactory.fromString(JSON, StringExpiresTokenResponse.class); 53 | assertEquals("2YotnFZFEjr1zCsicMWpAA", response.getAccessToken()); 54 | assertEquals("example", response.getTokenType()); 55 | assertEquals(3600L, response.getExpiresInSeconds().longValue()); 56 | assertEquals("tGzv3JOkF0XG5Qx2TlKWIA", response.getRefreshToken()); 57 | assertEquals("example_value", response.get("example_parameter")); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/PasswordTokenRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.auth.openidconnect.IdTokenResponse; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link PasswordTokenRequest}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class PasswordTokenRequestTest extends TestCase { 26 | 27 | private static final String USERNAME = "johndoe"; 28 | private static final String PASSWORD = "A3ddj3w"; 29 | 30 | public void testConstructor() { 31 | check( 32 | new PasswordTokenRequest( 33 | TokenRequestTest.TRANSPORT, 34 | TokenRequestTest.JSON_FACTORY, 35 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 36 | USERNAME, 37 | PASSWORD)); 38 | } 39 | 40 | private void check(PasswordTokenRequest request) { 41 | TokenRequestTest.check(request, "password"); 42 | assertEquals(USERNAME, request.getUsername()); 43 | assertEquals(PASSWORD, request.getPassword()); 44 | } 45 | 46 | public void testSetResponseClass() { 47 | PasswordTokenRequest request = 48 | new PasswordTokenRequest( 49 | TokenRequestTest.TRANSPORT, 50 | TokenRequestTest.JSON_FACTORY, 51 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 52 | USERNAME, 53 | PASSWORD) 54 | .setResponseClass(IdTokenResponse.class); 55 | assertEquals(IdTokenResponse.class, request.getResponseClass()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/RefreshTokenRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.auth.openidconnect.IdTokenResponse; 18 | import junit.framework.TestCase; 19 | 20 | /** 21 | * Tests {@link RefreshTokenRequest}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class RefreshTokenRequestTest extends TestCase { 26 | 27 | private static final String REFRESH_TOKEN = "tGzv3JOkF0XG5Qx2TlKWIA"; 28 | 29 | public void testConstructor() { 30 | check( 31 | new RefreshTokenRequest( 32 | TokenRequestTest.TRANSPORT, 33 | TokenRequestTest.JSON_FACTORY, 34 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 35 | REFRESH_TOKEN)); 36 | } 37 | 38 | private void check(RefreshTokenRequest request) { 39 | TokenRequestTest.check(request, "refresh_token"); 40 | assertEquals(REFRESH_TOKEN, request.getRefreshToken()); 41 | } 42 | 43 | public void testSetResponseClass() { 44 | RefreshTokenRequest request = 45 | new RefreshTokenRequest( 46 | TokenRequestTest.TRANSPORT, 47 | TokenRequestTest.JSON_FACTORY, 48 | TokenRequestTest.AUTHORIZATION_SERVER_URL, 49 | REFRESH_TOKEN) 50 | .setResponseClass(IdTokenResponse.class); 51 | assertEquals(IdTokenResponse.class, request.getResponseClass()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/TokenErrorResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.json.JsonFactory; 18 | import com.google.api.client.json.gson.GsonFactory; 19 | import junit.framework.TestCase; 20 | 21 | /** 22 | * Tests {@link TokenErrorResponse}. 23 | * 24 | * @author Yaniv Inbar 25 | */ 26 | public class TokenErrorResponseTest extends TestCase { 27 | 28 | private static final String JSON = 29 | "{\"error\":\"invalid_request\"," 30 | + "\"error_uri\":\"http://www.example.com/error\"," 31 | + "\"error_description\":\"error description\"}"; 32 | 33 | public void test() throws Exception { 34 | JsonFactory jsonFactory = new GsonFactory(); 35 | TokenErrorResponse response = jsonFactory.fromString(JSON, TokenErrorResponse.class); 36 | assertEquals("invalid_request", response.getError()); 37 | assertEquals("http://www.example.com/error", response.getErrorUri()); 38 | assertEquals("error description", response.getErrorDescription()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/java/com/google/api/client/auth/oauth2/TokenResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.auth.oauth2; 16 | 17 | import com.google.api.client.json.JsonFactory; 18 | import com.google.api.client.json.gson.GsonFactory; 19 | import junit.framework.TestCase; 20 | 21 | /** 22 | * Tests {@link TokenResponse}. 23 | * 24 | * @author Yaniv Inbar 25 | */ 26 | public class TokenResponseTest extends TestCase { 27 | 28 | private static final String JSON = 29 | "{\"access_token\":\"2YotnFZFEjr1zCsicMWpAA\"," 30 | + "\"token_type\":\"example\",\"expires_in\":3600," 31 | + "\"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\"," 32 | + "\"example_parameter\":\"example_value\"}"; 33 | 34 | public void test() throws Exception { 35 | JsonFactory jsonFactory = new GsonFactory(); 36 | TokenResponse response = jsonFactory.fromString(JSON, TokenResponse.class); 37 | assertEquals("2YotnFZFEjr1zCsicMWpAA", response.getAccessToken()); 38 | assertEquals("example", response.getTokenType()); 39 | assertEquals(3600L, response.getExpiresInSeconds().longValue()); 40 | assertEquals("tGzv3JOkF0XG5Qx2TlKWIA", response.getRefreshToken()); 41 | assertEquals("example_value", response.get("example_parameter")); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/aws_security_credentials.json: -------------------------------------------------------------------------------- 1 | { 2 | "Code" : "Success", 3 | "LastUpdated" : "2020-08-11T19:33:07Z", 4 | "Type" : "AWS-HMAC", 5 | "AccessKeyId" : "ASIARD4OQDT6A77FR3CL", 6 | "SecretAccessKey" : "Y8AfSaucF37G4PpvfguKZ3/l7Id4uocLXxX0+VTx", 7 | "Token" : "IQoJb3JpZ2luX2VjEIz//////////wEaCXVzLWVhc3QtMiJGMEQCIH7MHX/Oy/OB8OlLQa9GrqU1B914+iMikqWQW7vPCKlgAiA/Lsv8Jcafn14owfxXn95FURZNKaaphj0ykpmS+Ki+CSq0AwhlEAAaDDA3NzA3MTM5MTk5NiIMx9sAeP1ovlMTMKLjKpEDwuJQg41/QUKx0laTZYjPlQvjwSqS3OB9P1KAXPWSLkliVMMqaHqelvMF/WO/glv3KwuTfQsavRNs3v5pcSEm4SPO3l7mCs7KrQUHwGP0neZhIKxEXy+Ls//1C/Bqt53NL+LSbaGv6RPHaX82laz2qElphg95aVLdYgIFY6JWV5fzyjgnhz0DQmy62/Vi8pNcM2/VnxeCQ8CC8dRDSt52ry2v+nc77vstuI9xV5k8mPtnaPoJDRANh0bjwY5Sdwkbp+mGRUJBAQRlNgHUJusefXQgVKBCiyJY4w3Csd8Bgj9IyDV+Azuy1jQqfFZWgP68LSz5bURyIjlWDQunO82stZ0BgplKKAa/KJHBPCp8Qi6i99uy7qh76FQAqgVTsnDuU6fGpHDcsDSGoCls2HgZjZFPeOj8mmRhFk1Xqvkbjuz8V1cJk54d3gIJvQt8gD2D6yJQZecnuGWd5K2e2HohvCc8Fc9kBl1300nUJPV+k4tr/A5R/0QfEKOZL1/k5lf1g9CREnrM8LVkGxCgdYMxLQow1uTL+QU67AHRRSp5PhhGX4Rek+01vdYSnJCMaPhSEgcLqDlQkhk6MPsyT91QMXcWmyO+cAZwUPwnRamFepuP4K8k2KVXs/LIJHLELwAZ0ekyaS7CptgOqS7uaSTFG3U+vzFZLEnGvWQ7y9IPNQZ+Dffgh4p3vF4J68y9049sI6Sr5d5wbKkcbm8hdCDHZcv4lnqohquPirLiFQ3q7B17V9krMPu3mz1cg4Ekgcrn/E09NTsxAqD8NcZ7C7ECom9r+X3zkDOxaajW6hu3Az8hGlyylDaMiFfRbBJpTIlxp7jfa7CxikNgNtEKLH9iCzvuSg2vhA==", 8 | "Expiration" : "2020-08-11T07:35:49Z" 9 | } -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/certs.json: -------------------------------------------------------------------------------- 1 | { 2 | "keys": [ 3 | { 4 | "e": "AQAB", 5 | "n": "1qrQCTst3RF04aMC9Ye_kGbsE0sftL4FOtB_WrzBDOFdrfVwLfflQuPX5kJ-0iYv9r2mjD5YIDy8b-iJKwevb69ISeoOrmL3tj6MStJesbbRRLVyFIm_6L7alHhZVyqHQtMKX7IaNndrfebnLReGntuNk76XCFxBBnRaIzAWnzr3WN4UPBt84A0KF74pei17dlqHZJ2HB2CsYbE9Ort8m7Vf6hwxYzFtCvMCnZil0fCtk2OQ73l6egcvYO65DkAJibFsC9xAgZaF-9GYRlSjMPd0SMQ8yU9i3W7beT00Xw6C0FYA9JAYaGaOvbT87l_6ZkAksOMuvIPD_jNVfTCPLQ", 6 | "use": "sig", 7 | "kty": "RSA", 8 | "alg": "RS256", 9 | "kid": "6083dd5981673f661fde9dae646b6f0380a0145c" 10 | }, 11 | { 12 | "use": "sig", 13 | "alg": "RS256", 14 | "kid": "85ba9313fd7a7d4afa84884abcc8403004363180", 15 | "e": "AQAB", 16 | "kty": "RSA", 17 | "n": "pP-rCe4jkKX6mq8yP1GcBZcxJzmxKWicHHor1S3Q49u6Oe-bQsk5NsK5mdR7Y7liGV9n0ikXSM42dYKQdxbhKA-7--fFon5isJoHr4fIwL2CCwVm5QWlK37q6PiH2_F1M0hRorHfkCb4nI56ZvfygvuOH4LIS82OzIgmsYbeEfwDRpeMSxWKwlpa3pX3GZ6jG7FgzJGBvmBkagpgsa2JZdyU4gEGMOkHdSzi5Ii-6RGfFLhhI1OMxC9P2JaU5yjMN2pikfFIq_dbpm75yNUGpWJNVywtrlNvvJfA74UMN_lVCAaSR0A03BUMg6ljB65gFllpKF224uWBA8tpjngwKQ" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/client_secret.json: -------------------------------------------------------------------------------- 1 | { 2 | "web": { 3 | "client_id":"ya29.1.AADtN_UtlxN3PuGAxrN2XQnZTVRvDyVWnYq4I6dws", 4 | "auth_uri":"https://accounts.google.com/o/oauth2/auth", 5 | "token_uri":"https://accounts.google.com/o/oauth2/token", 6 | "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs", 7 | "client_secret":"jakuaL9YyieakhECKL2SwZcu", 8 | "redirect_uris":[ 9 | "http://example.appspot.com/oauth2callback", 10 | "http://localhost:8080/oauth2callback" 11 | ], 12 | "javascript_origins":[ 13 | "https://www.example.com" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/com/google/api/client/auth/security/secret.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-oauth-java-client/e771f812900b03c37f50c2ec6376998a178ee8c3/google-oauth-client/src/test/resources/com/google/api/client/auth/security/secret.p12 -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/com/google/api/client/auth/security/secret.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: privatekey 3 | localKeyID: 54 69 6D 65 20 31 33 35 34 33 37 38 32 34 35 33 30 35 4 | Key Attributes: 5 | -----BEGIN PRIVATE KEY----- 6 | MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAL1SdY8jTUVU7O4/ 7 | XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQGLW8Iftx9wfXe1zuaehJSgLcyCxazfyJ 8 | oN3RiONBihBqWY6d3lQKqkgsRTNZkdFJWdzl/6CxhK9sojh2p0r3tydtv9iwq5fu 9 | uWIvtODtT98EgphhncQAqkKoF3zVAgMBAAECgYB51B9cXe4yiGTzJ4pOKpHGySAy 10 | sC1F/IjXt2eeD3PuKv4m/hL4l7kScpLx0+NJuQ4j8U2UK/kQOdrGANapB1ZbMZAK 11 | /q0xmIUzdNIDiGSoTXGN2mEfdsEpQ/Xiv0lyhYBBPC/K4sYIpHccnhSRQUZlWLLY 12 | lE5cFNKC9b7226mNvQJBAPt0hfCNIN0kUYOA9jdLtx7CE4ySGMPf5KPBuzPd8ty1 13 | fxaFm9PB7B76VZQYmHcWy8rT5XjoLJHrmGW1ZvP+iDsCQQDAvnKoarPOGb5iJfkq 14 | RrA4flf1TOlf+1+uqIOJ94959jkkJeb0gv/TshDnm6/bWn+1kJylQaKygCizwPwB 15 | Z84vAkA0Duur4YvsPJijoQ9YY1SGCagCcjyuUKwFOxaGpmyhRPIKt56LOJqpzyno 16 | fy8ReKa4VyYq4eZYT249oFCwMwIBAkAROPNF2UL3x5UbcAkznd1hLujtIlI4IV4L 17 | XUNjsJtBap7we/KHJq11XRPlniO4lf2TW7iji5neGVWJulTKS1xBAkAerktk4Hsw 18 | ErUaUG1s/d+Sgc8e/KMeBElV+NxGhcWEeZtfHMn/6VOlbzY82JyvC9OKC80A5CAE 19 | VUV6b25kqrcu 20 | -----END PRIVATE KEY----- 21 | Bag Attributes 22 | friendlyName: privatekey 23 | localKeyID: 54 69 6D 65 20 31 33 35 34 33 37 38 32 34 35 33 30 35 24 | subject=/CN=1009120726878.apps.googleusercontent.com 25 | issuer=/CN=1009120726878.apps.googleusercontent.com 26 | -----BEGIN CERTIFICATE----- 27 | MIICGzCCAYSgAwIBAgIIWrt6xtmHPs4wDQYJKoZIhvcNAQEFBQAwMzExMC8GA1UE 28 | AxMoMTAwOTEyMDcyNjg3OC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbTAeFw0x 29 | MjEyMDExNjEwNDRaFw0yMjExMjkxNjEwNDRaMDMxMTAvBgNVBAMTKDEwMDkxMjA3 30 | MjY4NzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20wgZ8wDQYJKoZIhvcNAQEB 31 | BQADgY0AMIGJAoGBAL1SdY8jTUVU7O4/XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQ 32 | GLW8Iftx9wfXe1zuaehJSgLcyCxazfyJoN3RiONBihBqWY6d3lQKqkgsRTNZkdFJ 33 | Wdzl/6CxhK9sojh2p0r3tydtv9iwq5fuuWIvtODtT98EgphhncQAqkKoF3zVAgMB 34 | AAGjODA2MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQM 35 | MAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAD8XQEqzGePa9VrvtEGpf+R4 36 | fkxKbcYAzqYq202nKu0kfjhIYkYSBj6gi348YaxE64yu60TVl42l5HThmswUheW4 37 | uQIaq36JvwvsDP5Zoj5BgiNSnDAFQp+jJFBRUA5vooJKgKgMDf/r/DCOsbO6VJF1 38 | kWwa9n19NFiV0z3m6isj 39 | -----END CERTIFICATE----- 40 | -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/federated_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "keys": [ 3 | { 4 | "kid": "f9d97b4cae90bcd76aeb20026f6b770cac221783", 5 | "e": "AQAB", 6 | "kty": "RSA", 7 | "alg": "RS256", 8 | "n": "ya_7gVJrvqFp5xfYPOco8gBLY38kQDlTlT6ueHtUtbTkRVE1X5tFmPqChnX7wWd2fK7MS4-nclYaGLL7IvJtN9tjrD0h_3_HvnrRZTaVyS-yfWqCQDRq_0VW1LBEygwYRqbO2T0lOocTY-5qUosDvJfe-o-lQYMH7qtDAyiq9XprVzKYTfS545BTECXi0he9ikJl5Q_RAP1BZoaip8F0xX5Y_60G90VyXFWuy16nm5ASW8fwqzdn1lL_ogiO1LirgBFFEXz_t4PwmjWzfQwkoKv4Ab_l9u2FdAoKtFH2CwKaGB8hatIK3bOAJJgRebeU3w6Ah3gxRfi8HWPHbAGjtw", 9 | "use": "sig" 10 | }, 11 | { 12 | "kid": "28b741e8de984a47159f19e6d7783e9d4fa810db", 13 | "e": "AQAB", 14 | "kty": "RSA", 15 | "alg": "RS256", 16 | "n": "zc4ELn-9nLzCZb4PdXGVhtUtzwmQI8HZH8tOIEg9omx6CW-PZ5xtVQ5O5EBG2AA5_K-aOWvVEWyfeHe8WwZltM1cXu6QNdXbpVVYeZ0th9hm7ZflNz7h1PMM9lNXLJjokax5gxGskc8CsjhkwurEot1TD2zbGIQsOYoebQTvJ2AYxIjk77BU20nLplurge8jrK-V1G3zJlp0xIKqxjsfIFYm1Mp-HQhJzdMbjNEScs0dDT4rPxdA-wOVGix0wrPdIE1gM4GxZ7AlSZ7IcjuYMZIe6d6oAeKG0FG0avbtipAQglxTHM3UOge6PmThr_mmiI82oLqGutul-XYgy1S2NQ", 17 | "use": "sig" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/iap_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "keys" : [ 3 | { 4 | "alg" : "ES256", 5 | "crv" : "P-256", 6 | "kid" : "2nMJtw", 7 | "kty" : "EC", 8 | "use" : "sig", 9 | "x" : "9e1x7YRZg53A5zIJ0p2ZQ9yTrgPLGIf4ntOk-4O2R28", 10 | "y" : "q8iDm7nsnpz1xPdrWBtTZSowzciS3O7bMYtFFJ8saYo" 11 | }, 12 | { 13 | "alg" : "ES256", 14 | "crv" : "P-256", 15 | "kid" : "LYyP2g", 16 | "kty" : "EC", 17 | "use" : "sig", 18 | "x" : "SlXFFkJ3JxMsXyXNrqzE3ozl_0913PmNbccLLWfeQFU", 19 | "y" : "GLSahrZfBErmMUcHP0MGaeVnJdBwquhrhQ8eP05NfCI" 20 | }, 21 | { 22 | "alg" : "ES256", 23 | "crv" : "P-256", 24 | "kid" : "mpf0DA", 25 | "kty" : "EC", 26 | "use" : "sig", 27 | "x" : "fHEdeT3a6KaC1kbwov73ZwB_SiUHEyKQwUUtMCEn0aI", 28 | "y" : "QWOjwPhInNuPlqjxLQyhveXpWqOFcQPhZ3t-koMNbZI" 29 | }, 30 | { 31 | "alg" : "ES256", 32 | "crv" : "P-256", 33 | "kid" : "b9vTLA", 34 | "kty" : "EC", 35 | "use" : "sig", 36 | "x" : "qCByTAvci-jRAD7uQSEhTdOs8iA714IbcY2L--YzynI", 37 | "y" : "WQY0uCoQyPSozWKGQ0anmFeOH5JNXiZa9i6SNqOcm7w" 38 | }, 39 | { 40 | "alg" : "ES256", 41 | "crv" : "P-256", 42 | "kid" : "0oeLcQ", 43 | "kty" : "EC", 44 | "use" : "sig", 45 | "x" : "MdhRXGEoGJLtBjQEIjnYLPkeci9rXnca2TffkI0Kac0", 46 | "y" : "9BoREHfX7g5OK8ELpA_4RcOnFCGSjfR4SGZpBo7juEY" 47 | } 48 | ] 49 | } -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/legacy_federated_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "f9d97b4cae90bcd76aeb20026f6b770cac221783": "-----BEGIN CERTIFICATE-----\nMIIDJjCCAg6gAwIBAgIILRTfnfU3e2gwDQYJKoZIhvcNAQEFBQAwNjE0MDIGA1UE\nAxMrZmVkZXJhdGVkLXNpZ25vbi5zeXN0ZW0uZ3NlcnZpY2VhY2NvdW50LmNvbTAe\nFw0yMDA0MTQwNDI5MzBaFw0yMDA0MzAxNjQ0MzBaMDYxNDAyBgNVBAMTK2ZlZGVy\nYXRlZC1zaWdub24uc3lzdGVtLmdzZXJ2aWNlYWNjb3VudC5jb20wggEiMA0GCSqG\nSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDJr/uBUmu+oWnnF9g85yjyAEtjfyRAOVOV\nPq54e1S1tORFUTVfm0WY+oKGdfvBZ3Z8rsxLj6dyVhoYsvsi8m0322OsPSH/f8e+\netFlNpXJL7J9aoJANGr/RVbUsETKDBhGps7ZPSU6hxNj7mpSiwO8l976j6VBgwfu\nq0MDKKr1emtXMphN9LnjkFMQJeLSF72KQmXlD9EA/UFmhqKnwXTFflj/rQb3RXJc\nVa7LXqebkBJbx/CrN2fWUv+iCI7UuKuAEUURfP+3g/CaNbN9DCSgq/gBv+X27YV0\nCgq0UfYLApoYHyFq0grds4AkmBF5t5TfDoCHeDFF+LwdY8dsAaO3AgMBAAGjODA2\nMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsG\nAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4IBAQA1Wrx3XsIAAYOaycAkV2mZW1j+Vqxx\nSAeUyuhLoaJ7jntd7LqTuTr+qRnR/fH/CjTbPzngvCyVE6hjClh159YRpf4TJ4aL\nMJ97qDxc/f/pM/7yklIaHHOwqYU10plIyw+m0dnQutPqy1o/aDUytDznNmM6L3v+\ncot2bxyd2PtjGfa1hPNNnEnrZfS2Gc0qqR64RUWbsdLVVQB8MKcaNUqjk9o/1O4p\nNNk2D2VcofdaLPpwSmtzV8wEd4vfzI17qFSPi6gbTfydvxkejk0kdSyWUPw+1YC4\nv2o2rzwXub9hcP2zXyZvTGKPMAkZ8VKuzWuvfuSsTtgcPJ20GpIkin/j\n-----END CERTIFICATE-----\n", 3 | "28b741e8de984a47159f19e6d7783e9d4fa810db": "-----BEGIN CERTIFICATE-----\nMIIDJjCCAg6gAwIBAgIIcog+uwMaMb8wDQYJKoZIhvcNAQEFBQAwNjE0MDIGA1UE\nAxMrZmVkZXJhdGVkLXNpZ25vbi5zeXN0ZW0uZ3NlcnZpY2VhY2NvdW50LmNvbTAe\nFw0yMDA0MjIwNDI5MzBaFw0yMDA1MDgxNjQ0MzBaMDYxNDAyBgNVBAMTK2ZlZGVy\nYXRlZC1zaWdub24uc3lzdGVtLmdzZXJ2aWNlYWNjb3VudC5jb20wggEiMA0GCSqG\nSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNzgQuf72cvMJlvg91cZWG1S3PCZAjwdkf\ny04gSD2ibHoJb49nnG1VDk7kQEbYADn8r5o5a9URbJ94d7xbBmW0zVxe7pA11dul\nVVh5nS2H2Gbtl+U3PuHU8wz2U1csmOiRrHmDEayRzwKyOGTC6sSi3VMPbNsYhCw5\nih5tBO8nYBjEiOTvsFTbScumW6uB7yOsr5XUbfMmWnTEgqrGOx8gVibUyn4dCEnN\n0xuM0RJyzR0NPis/F0D7A5UaLHTCs90gTWAzgbFnsCVJnshyO5gxkh7p3qgB4obQ\nUbRq9u2KkBCCXFMczdQ6B7o+ZOGv+aaIjzaguoa626X5diDLVLY1AgMBAAGjODA2\nMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsG\nAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4IBAQBEfCN7qgI2GJJAC99PDbafqC1EMBlv\nBT/7UiQdTuDV04+cQH9IpzROW7IZc/ILcqpF6KXUmj6j0sWO+hxKFY66TJKPcypK\n/ZMI58epwwVgGZyYU0BbAIZ9uvOgDfuveMildlMDMg1cJNp7WjBrEJ2DcGfC56wJ\nuKvqB1upxnfh+Ceg3ApU50k6Ld6+dbDDR0Vzt/wGZlZZ5Uj6AwDFe+5p9zEpWg61\nHeny/tSBfgZ19vP2h3ye9ZTK1OFRMNufj8iSzmlkbSqWuy82XVSBRKy5QslqXsYe\nU3gM3EVvXHA/Of3sROFpvznCXNr+Kn03wTv0ny6rnSgHQUzj7p9fydXY\n-----END CERTIFICATE-----\n" 4 | } -------------------------------------------------------------------------------- /google-oauth-client/src/test/resources/service_account_keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "a8611b6a9c0a0a8b940d0f915c326fd1605c8ac6": "-----BEGIN CERTIFICATE-----\nMIIDPDCCAiSgAwIBAgIIFJsPvyc/ZSUwDQYJKoZIhvcNAQEFBQAwQTE/MD0GA1UE\nAxM2aW50ZWdyYXRpb24tdGVzdHMuY2hpbmdvci10ZXN0LmlhbS5nc2VydmljZWFj\nY291bnQuY29tMB4XDTIwMDQwMjIyMjIxN1oXDTIyMDUwMTEzNTYxNVowQTE/MD0G\nA1UEAxM2aW50ZWdyYXRpb24tdGVzdHMuY2hpbmdvci10ZXN0LmlhbS5nc2Vydmlj\nZWFjY291bnQuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6Yys\nP5LIa1rRxQY93FXIJDzq6Tai4VuetffJbltRtYbdwC5Vyl99O2zoVdRlg+iYXK5B\nb6kidjmWOf0kNimQ5FwYvu+xsm6w8vjL/XShkHEKiURszyCua8wvLeGVCiGBg/XU\nDOgYMjzRIH5fTuj3PTZk4sMj02ZCpCQEMQ6ogpLXjaLp3ZXtFhkuHyCxVYbTRr+k\nGU86JAg4XwD6AdC349v+8FEQD7YtJezUAAKEgXh9e5UeL5CpOo3Vsdv/yEVo00jh\nYuWzLM6Oxt55WAhiD29vKrm7VQPSr1XwwqpdyFL2BlmqyTlb3amwvc9qv2kojGvM\nSUqgS83dc0jFqtMvEQIDAQABozgwNjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQE\nAwIHgDAWBgNVHSUBAf8EDDAKBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOCAQEA\nm3XUMKOtXdpw0oRjykLHdYzTHHFjQTMmhWD172rsxSzwpkFoErAC7bnmEvpcRU7D\nr4M+pE5VuDJ64J3lEpAh7W0zMXezPtGyWr39hVxL3vp3nh4CbCzzkUCfFvBOFFhm\nOI9qnjtMtaozoGi5zLs5jEaFmgR3wfij9KQjNGZJxAg0ZkwcSNb76qOCG1/vG5au\n4UuoIaq8WqSxMqBF/g+NrAE2PZhjNGnUwFPTre3SyR0otYDzJfmpL/tp5VDie8hM\nL5UZU/CmZk46+T9VbvnZ5mkPAjGiPumiptO5iliBOHPtPdn8VrP+aSQM1btHA094\n1HwfbFp7pZHBUn9COAP/1Q==\n-----END CERTIFICATE-----\n", 3 | "2ef77b38a1b0370487043916acbf27d74edd08b1": "-----BEGIN CERTIFICATE-----\nMIIC+jCCAeKgAwIBAgIIIwRR4+AftjswDQYJKoZIhvcNAQEFBQAwIDEeMBwGA1UE\nAxMVMTA0MDI5MjkyODUzMDk5OTc4MjkzMB4XDTIwMDMwNDA1NTIyMloXDTMwMDMw\nMjA1NTIyMlowIDEeMBwGA1UEAxMVMTA0MDI5MjkyODUzMDk5OTc4MjkzMIIBIjAN\nBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm4jAbNdDEDkG/36wP07lFKMTAnWy\nhtV/Vp4QFSIE456moU/HEmBwJX2wocPgvoxPat7FxUv7mwdgHq7+sczis4DrDIIY\n8XfZ+D98+X+rOfkS1WLXpO76REZE4JCUfkB3NKVMP0kfoCFPf2pafz1NJRrZczUw\nbSi/q1+KYHmbk8YS+Q7Iq7gW9dvQtWrsRH8dQIrToJfGH+rbSQyKUFN7skFOflw4\n/OSuT0wvD6z57JcRFtAD3zgeUuCPNRIbkPQC3vCLwWGLKSYWLJ3eM9PPW9bk+czf\nSxJOie7zRMToh4BchLO6ZQgshoEaBHbwdOTu8455skqlRJMU9SKwA6eqVQIDAQAB\nozgwNjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIHgDAWBgNVHSUBAf8EDDAK\nBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOCAQEAXvt8M2GFK+5UHG0GclIqse8j\n+EgqXvDTkbeTxFP+onbA/RwKM+fzdYpDwrH1dQ6jJervmceewUTTMegfFzhF33GC\nxvjQfhs+yVOXQiBHosd93CgR19dMUYs/r1wuUpwqBGdW2S81ns3yreY72BHrikrl\nHNLD3aSJ6hq5CZ01EFpjTW10ndBdPhJRSWD2g8VI1lpd716HEmrXfPHX73KVkk5/\nWfvrMA1UK/Ag+TWQerKG3iQFUAPIUiyepdaG4uFWTBY9nzLPiC1cx3bVPVZ+5yul\nJN15hmAMd3qPgSbbeQ6JC72zXCfW3buBE2n9cGtRbZF1URJZ3NbvwRS5BD425g==\n-----END CERTIFICATE-----\n" 4 | } -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | ":separateMajorReleases", 4 | ":combinePatchMinorReleases", 5 | ":ignoreUnstable", 6 | ":prImmediately", 7 | ":updateNotScheduled", 8 | ":automergeDisabled", 9 | ":ignoreModulesAndTests", 10 | ":maintainLockFilesDisabled", 11 | ":autodetectPinVersions" 12 | ], 13 | "packageRules": [ 14 | { 15 | "packagePatterns": [ 16 | "^com.google.guava:" 17 | ], 18 | "versionScheme": "docker" 19 | }, 20 | { 21 | "packagePatterns": ["^com.google.appengine:appengine-"], 22 | "groupName": "AppEngine packages" 23 | } 24 | ], 25 | "dependencyDashboard": true 26 | } 27 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/README.md: -------------------------------------------------------------------------------- 1 | # Instructions for the Daily Motion OAuth2 Command-Line Sample 2 | 3 | ## Browse Online 4 | 5 | [Browse Source][browse-source], or main file [DailyMotionSample.java][main-source]. 6 | 7 | ## Command-Line Instructions 8 | 9 | **Prerequisites:** install [Java 7 or higher][install-java], [git][install-git], and 10 | [Maven][install-maven]. You may need to set your `JAVA_HOME`. 11 | 12 | 1. Check out the sample code: 13 | 14 | ```bash 15 | git clone https://github.com/google/google-oauth-java-client.git 16 | cd google-oauth-java-client/samples/dailymotion-cmdline-sample 17 | ``` 18 | 19 | 2. Edit the `OAuth2ClientCredentials.java` file with your credentials. To acquire credentials, go 20 | to the [Dailymotion Developer Profile][dailymotion-developer-profile], click "Create New API Key" 21 | and specify "http://127.0.0.1:8080/Callback" as the "Callback URL". 22 | 23 | 3. Run the sample: 24 | 25 | ```bash 26 | mvn compile 27 | mvn -q exec:java 28 | ``` 29 | 30 | 31 | [browse-source]: https://github.com/google/google-oauth-java-client/tree/dev/samples/dailymotion-cmdline-sample 32 | [main-source]: https://github.com/google/google-oauth-java-client/blob/dev/samples/dailymotion-cmdline-sample/src/main/java/com/google/api/services/samples/dailymotion/cmdline/DailyMotionSample.java 33 | [install-java]: https://java.com/ 34 | [install-git]: https://git-scm.com 35 | [install-maven]: https://maven.apache.org 36 | [dailymotion-developer-profile]: https://www.dailymotion.com/profile/developer 37 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/logging.properties: -------------------------------------------------------------------------------- 1 | # Properties file which configures the operation of the JDK logging facility. 2 | # The system will look for this config file to be specified as a system property: 3 | # -Djava.util.logging.config.file=${project_loc:dailymotion-cmdline-sample}/logging.properties 4 | 5 | # Set up the console handler (uncomment "level" to show more fine-grained messages) 6 | handlers = java.util.logging.ConsoleHandler 7 | #java.util.logging.ConsoleHandler.level = CONFIG 8 | 9 | # Set up logging of HTTP requests and responses (uncomment "level" to show) 10 | #com.google.api.client.http.level = CONFIG 11 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/src/main/java/com/google/api/services/samples/dailymotion/cmdline/DailyMotionUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.services.samples.dailymotion.cmdline; 16 | 17 | import com.google.api.client.http.GenericUrl; 18 | import com.google.api.client.util.Key; 19 | 20 | /** 21 | * URL for Dailymotion API. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class DailyMotionUrl extends GenericUrl { 26 | 27 | @Key private String fields; 28 | 29 | public DailyMotionUrl(String encodedUrl) { 30 | super(encodedUrl); 31 | } 32 | 33 | /** @return the fields */ 34 | public String getFields() { 35 | return fields; 36 | } 37 | 38 | /** @param fields the fields to set */ 39 | public void setFields(String fields) { 40 | this.fields = fields; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/src/main/java/com/google/api/services/samples/dailymotion/cmdline/OAuth2ClientCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.services.samples.dailymotion.cmdline; 16 | 17 | /** 18 | * OAuth 2 credentials found in the Developer 19 | * Profile Page. 20 | * 21 | *

Once at the Developer Profile page, you will need to create a Daily Motion account if you do 22 | * not already have one. Click on "Create a new API Key". Enter "http://127.0.0.1:8080/Callback" 23 | * under "Callback URL" and select "Native Application" under "Application Profile". Enter a port 24 | * number other than 8080 if that is what you intend to use. 25 | * 26 | * @author Ravi Mistry 27 | */ 28 | public class OAuth2ClientCredentials { 29 | 30 | /** Value of the "API Key". */ 31 | public static final String API_KEY = "Enter API Key"; 32 | 33 | /** Value of the "API Secret". */ 34 | public static final String API_SECRET = "Enter API Secret"; 35 | 36 | /** Port in the "Callback URL". */ 37 | public static final int PORT = 8080; 38 | 39 | /** Domain name in the "Callback URL". */ 40 | public static final String DOMAIN = "127.0.0.1"; 41 | 42 | public static void errorIfNotSpecified() { 43 | if (API_KEY.startsWith("Enter ") || API_SECRET.startsWith("Enter ")) { 44 | System.out.println( 45 | "Enter API Key and API Secret from http://www.dailymotion.com/profile/developer" 46 | + " into API_KEY and API_SECRET in " 47 | + OAuth2ClientCredentials.class); 48 | System.exit(1); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/src/main/java/com/google/api/services/samples/dailymotion/cmdline/Video.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.services.samples.dailymotion.cmdline; 16 | 17 | import com.google.api.client.util.Key; 18 | import java.util.List; 19 | 20 | /** @author Yaniv Inbar */ 21 | public class Video { 22 | 23 | @Key public String id; 24 | 25 | @Key public List tags; 26 | 27 | @Key public String title; 28 | 29 | @Key public String url; 30 | } 31 | -------------------------------------------------------------------------------- /samples/dailymotion-cmdline-sample/src/main/java/com/google/api/services/samples/dailymotion/cmdline/VideoFeed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.services.samples.dailymotion.cmdline; 16 | 17 | import com.google.api.client.util.Key; 18 | import java.util.List; 19 | 20 | /** @author Yaniv Inbar */ 21 | public class VideoFeed { 22 | 23 | @Key public List