copilot.lua autocomplete and opencode auth Github Copilot invalidate eachothers' auth tokens #1745

Closed
opened 2026-02-16 17:32:26 -05:00 by yindo · 9 comments
Owner

Originally created by @ian-pascoe on GitHub (Sep 17, 2025).

Originally assigned to: @rekram1-node on GitHub.

While using copilot.lua and opencode with github copilot, when I login with one, the token for the other is invalidated. This makes it impossible to use them simultaneously.

Originally created by @ian-pascoe on GitHub (Sep 17, 2025). Originally assigned to: @rekram1-node on GitHub. While using copilot.lua and opencode with github copilot, when I login with one, the token for the other is invalidated. This makes it impossible to use them simultaneously.
yindo closed this issue 2026-02-16 17:32:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 17, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #316: Discusses the same underlying OAuth app ID reuse between opencode and neovim copilot plugin that could cause token conflicts

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Sep 17, 2025): This issue might be a duplicate of existing issues. Please check: - #316: Discusses the same underlying OAuth app ID reuse between opencode and neovim copilot plugin that could cause token conflicts Feel free to ignore if none of these address your specific case.
Author
Owner

@ian-pascoe commented on GitHub (Sep 17, 2025):

This issue might be a duplicate of existing issues. Please check:

Feel free to ignore if none of these address your specific case.

If this is the case then it is expected for them not be used in tandem? Kinda sucks

@ian-pascoe commented on GitHub (Sep 17, 2025): > This issue might be a duplicate of existing issues. Please check: > > * [potential misconfiguration: Copilot Auth Flow #316](https://github.com/sst/opencode/issues/316): Discusses the same underlying OAuth app ID reuse between opencode and neovim copilot plugin that could cause token conflicts > > Feel free to ignore if none of these address your specific case. If this is the case then it is expected for them not be used in tandem? Kinda sucks
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

I think that maybe be a limitation of the copilot api right? The work around is you could copy the token from one and paste into another to prevent getting logged out, example:

if you have the access & refresh tokens for 1 just update the other to match

@rekram1-node commented on GitHub (Sep 17, 2025): I think that maybe be a limitation of the copilot api right? The work around is you could copy the token from one and paste into another to prevent getting logged out, example: if you have the access & refresh tokens for 1 just update the other to match
Author
Owner

@ian-pascoe commented on GitHub (Sep 17, 2025):

Perhaps, but should be addressed so that users can use both without clashing.

@ian-pascoe commented on GitHub (Sep 17, 2025): Perhaps, but should be addressed so that users can use both without clashing.
Author
Owner

@ian-pascoe commented on GitHub (Sep 17, 2025):

Where is the location of the two tokens for me to copy/paste from one another?

@ian-pascoe commented on GitHub (Sep 17, 2025): Where is the location of the two tokens for me to copy/paste from one another?
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

You can find them in: ~/.local/share/opencode/auth.json

@rekram1-node commented on GitHub (Sep 17, 2025): You can find them in: ~/.local/share/opencode/auth.json
Author
Owner

@lucobellic commented on GitHub (Sep 18, 2025):

I have the same issue.
Copying the refresh token from ~/.local/share/opencode/auth.json to the oauth_token field in ~/.config/github-copilot/apps.json seems to work.

@lucobellic commented on GitHub (Sep 18, 2025): I have the same issue. Copying the `refresh` token from `~/.local/share/opencode/auth.json` to the `oauth_token` field in `~/.config/github-copilot/apps.json` seems to work.
Author
Owner

@rekram1-node commented on GitHub (Sep 18, 2025):

Yeah I don't think there is anything to do on our end here, this seems like a limitation of their api closing for now

@rekram1-node commented on GitHub (Sep 18, 2025): Yeah I don't think there is anything to do on our end here, this seems like a limitation of their api closing for now
Author
Owner

@ian-pascoe commented on GitHub (Oct 16, 2025):

For anyone trying to automate this sync, I wrote a script that I just put on my path, and run it whenever I auth into either instance:

#!/bin/bash

set -e

AUTH_FILE="$HOME/.local/share/opencode/auth.json"
APPS_FILE="$HOME/.config/github-copilot/apps.json"

if [ ! -f "$AUTH_FILE" ]; then
  echo "Error: $AUTH_FILE not found"
  exit 1
fi

if [ ! -f "$APPS_FILE" ]; then
  echo "Error: $APPS_FILE not found"
  exit 1
fi

AUTH_MTIME=$(stat -c %Y "$AUTH_FILE" 2>/dev/null || stat -f %m "$AUTH_FILE")
APPS_MTIME=$(stat -c %Y "$APPS_FILE" 2>/dev/null || stat -f %m "$APPS_FILE")

REFRESH_TOKEN=$(jq -r '.["github-copilot"].refresh' "$AUTH_FILE")
OAUTH_TOKEN=$(jq -r '.[] | .oauth_token' "$APPS_FILE" | head -n1)

if [ -z "$REFRESH_TOKEN" ] || [ "$REFRESH_TOKEN" = "null" ]; then
  echo "Error: Could not extract refresh token from $AUTH_FILE"
  exit 1
fi

if [ -z "$OAUTH_TOKEN" ] || [ "$OAUTH_TOKEN" = "null" ]; then
  echo "Error: Could not extract oauth_token from $APPS_FILE"
  exit 1
fi

if [ "$REFRESH_TOKEN" = "$OAUTH_TOKEN" ]; then
  echo "Tokens are already in sync"
  exit 0
fi

if [ "$AUTH_MTIME" -gt "$APPS_MTIME" ]; then
  echo "Syncing from $AUTH_FILE to $APPS_FILE (auth.json is newer)"
  jq --arg token "$REFRESH_TOKEN" '.[] |= (.oauth_token = $token)' "$APPS_FILE" >"${APPS_FILE}.tmp"
  mv "${APPS_FILE}.tmp" "$APPS_FILE"
elif [ "$APPS_MTIME" -gt "$AUTH_MTIME" ]; then
  echo "Syncing from $APPS_FILE to $AUTH_FILE (apps.json is newer)"
  jq --arg token "$OAUTH_TOKEN" '.["github-copilot"].refresh = $token' "$AUTH_FILE" >"${AUTH_FILE}.tmp"
  mv "${AUTH_FILE}.tmp" "$AUTH_FILE"
else
  echo "Files are in sync (both have same modification time)"
fi
@ian-pascoe commented on GitHub (Oct 16, 2025): For anyone trying to automate this sync, I wrote a script that I just put on my path, and run it whenever I auth into either instance: ```bash #!/bin/bash set -e AUTH_FILE="$HOME/.local/share/opencode/auth.json" APPS_FILE="$HOME/.config/github-copilot/apps.json" if [ ! -f "$AUTH_FILE" ]; then echo "Error: $AUTH_FILE not found" exit 1 fi if [ ! -f "$APPS_FILE" ]; then echo "Error: $APPS_FILE not found" exit 1 fi AUTH_MTIME=$(stat -c %Y "$AUTH_FILE" 2>/dev/null || stat -f %m "$AUTH_FILE") APPS_MTIME=$(stat -c %Y "$APPS_FILE" 2>/dev/null || stat -f %m "$APPS_FILE") REFRESH_TOKEN=$(jq -r '.["github-copilot"].refresh' "$AUTH_FILE") OAUTH_TOKEN=$(jq -r '.[] | .oauth_token' "$APPS_FILE" | head -n1) if [ -z "$REFRESH_TOKEN" ] || [ "$REFRESH_TOKEN" = "null" ]; then echo "Error: Could not extract refresh token from $AUTH_FILE" exit 1 fi if [ -z "$OAUTH_TOKEN" ] || [ "$OAUTH_TOKEN" = "null" ]; then echo "Error: Could not extract oauth_token from $APPS_FILE" exit 1 fi if [ "$REFRESH_TOKEN" = "$OAUTH_TOKEN" ]; then echo "Tokens are already in sync" exit 0 fi if [ "$AUTH_MTIME" -gt "$APPS_MTIME" ]; then echo "Syncing from $AUTH_FILE to $APPS_FILE (auth.json is newer)" jq --arg token "$REFRESH_TOKEN" '.[] |= (.oauth_token = $token)' "$APPS_FILE" >"${APPS_FILE}.tmp" mv "${APPS_FILE}.tmp" "$APPS_FILE" elif [ "$APPS_MTIME" -gt "$AUTH_MTIME" ]; then echo "Syncing from $APPS_FILE to $AUTH_FILE (apps.json is newer)" jq --arg token "$OAUTH_TOKEN" '.["github-copilot"].refresh = $token' "$AUTH_FILE" >"${AUTH_FILE}.tmp" mv "${AUTH_FILE}.tmp" "$AUTH_FILE" else echo "Files are in sync (both have same modification time)" fi ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1745