Skip to content

Generate a personal access token (classic) to access maven reposiotry #129

Closed

Description

@pawel-jedruch-swiftpay

We do have two private repositories in our organization, let's call them: library and project. The library is hosted in the Maven GitHub repository. The project workflow is using a personal access token for authorization (according to documentation.

Now we want to migrate to actions/create-github-app-token, but I was unable to create a working solution.

.github/workflows/example.yml
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Get token from Github App
      uses: actions/create-github-app-token@v1
      id: app-token
      with:
        app-id: ${{ secrets.GET_TOKEN_APP_ID }}
        private-key: ${{ secrets.GET_TOKEN_APP_PRIVATE_KEY }}
        owner: ${{ github.repository_owner }}
 
    - name: Set up Maven
      uses: actions/setup-java@v4
      with:
        java-version: '17'
        distribution: 'corretto'
        cache: 'maven'
        server-username: MAVEN_USERNAME
        server-password: MAVEN_PASSWORD

    - name: Build and Package
      run: |
        cd project
        mvn clean package
      env:
        MAVEN_USERNAME: ${{ github.actor }}
        MAVEN_PASSWORD: ${{ steps.app-token.outputs.token }}

I've tried multiple configurations but always end up with the following error:

Authentication failed for https://maven.pkg.github.com//repo/..., status: 401 Unauthorized -> [Help 1]

What I'm guessing is that create-github-app-token doesn't support a personal access token. Could you confirm if this is the case?

Activity

  1. gr2m commented on Apr 22, 2024

    @gr2m
    Contributor

    What I'm guessing is that create-github-app-token doesn't support a personal access token. Could you confirm if this is the case?

    That is correct, actions/create-github-app-token creates installation access token (server-to-server tokens). Personal access tokens cannot be created programmatically without user interaction.

    Authentication failed for https://maven.pkg.github.com//repo/...

    The // looks odd, maybe an argument is missing, like an org name? I'm not familiar with maven I'm afraid

  2. locked and limited conversation to collaborators on Apr 22, 2024
  3. converted this issue into a discussion #130 on Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions