Skip to content

Not able to login programatically using PAT token #233

@vardaan-gupta

Description

@vardaan-gupta

Describe the bug

I am trying to authenticate using Github Token, I have configured in secrets and variables in my repo.
The token has copilot requests access.
I am also able to login with same PAT token and execute copilot commands using interactive mode.

However, when i use the token in a workflow file below it is giving me error.

FILE

on:
  schedule:
    - cron: '0 0 * * *'  # Runs at 12:00 AM (midnight) UTC daily
  workflow_dispatch:  # Manual trigger

jobs:
  run-command:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '22'
        
    - name: Install GitHub Copilot CLI
      run: |
        echo "Installing GitHub Copilot CLI at $(date)"
        npm install -g @github/copilot
        
    - name: Authenticate and use GitHub Copilot
      env:
        GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }}
      run: |
        echo "Authenticating with GitHub Copilot"
        copilot --version
        echo $GITHUB_TOKEN
        
        echo "using Copilot"
        copilot -p "Generate unit test cases with spring test framework " --allow-all-tools

Execution Log

Run echo "Authenticating with GitHub Copilot"
  echo "Authenticating with GitHub Copilot"
  copilot --version
  echo $GITHUB_TOKEN
  
  echo "Generating documentation with Copilot"
  copilot -p "create a Documentation.md file and add below documentation - Provide a high-level description of the repository purpose and functionality - Include information about the system architecture and main components - Explain how different parts of the system interact with each other" --allow-all-tools
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
Authenticating with GitHub Copilot
0.0.335
Commit: 48dc015
***
Generating documentation with Copilot
**Error: No authentication information found.**

Copilot can be authenticated with GitHub using an OAuth Token or a Fine-Grained Personal Access Token.

To authenticate, you can use any of the following methods:
  • Start 'copilot' and run the '/login' command
  • Set the GH_TOKEN or GITHUB_TOKEN environment variable
  • Run 'gh auth login' to authenticate with the GitHub CLI
**Error: Process completed with exit code 1.**

Affected version

0.0.335

Steps to reproduce the behavior

  1. configure a PAT token in your repo.
  2. add above workflow file in you github repo.
  3. execute the workflow file.

Expected behavior

Copilot should login using GITHUB_TOKEN env variable.

Additional context

I am using personal Github Account for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions