|
10 | 10 | if [ $# -ne 2 ]; then |
11 | 11 | echo "Usage: $0 <org> <project-number>" |
12 | 12 | echo "Example: ./get-project-board-items.sh my-org 123" |
| 13 | + echo "Example: ./get-project-board-items.sh my-org 123" > results.txt |
13 | 14 | echo "" |
14 | 15 | echo "Note: This script works with Projects V2 (the newer project boards)" |
15 | 16 | echo "To find project number, check the URL: github.com/orgs/ORG/projects/NUMBER" |
@@ -145,7 +146,26 @@ response=$(gh api graphql --paginate -f org="$org" -F projectNumber="$project_nu |
145 | 146 |
|
146 | 147 | # Check for errors |
147 | 148 | if [ $? -ne 0 ]; then |
148 | | - if echo "$response" | grep -q "Could not resolve to a ProjectV2"; then |
| 149 | + if echo "$response" | grep -q "INSUFFICIENT_SCOPES"; then |
| 150 | + echo "❌ Error: Your GitHub token doesn't have the required permissions" |
| 151 | + echo "" |
| 152 | + echo "🔐 Required scope: 'read:project'" |
| 153 | + echo "" |
| 154 | + echo "Your token currently has these scopes:" |
| 155 | + # Extract current scopes from the error message |
| 156 | + current_scopes=$(echo "$response" | grep -o "but your token has only been granted the: \[.*\]" | sed "s/.*\[\(.*\)\].*/\1/" | tr ',' '\n' | sed "s/['\", ]//g" | grep -v "^$" | sort | uniq) |
| 157 | + if [ -n "$current_scopes" ]; then |
| 158 | + echo "$current_scopes" | sed 's/^/ • /' |
| 159 | + else |
| 160 | + echo " • (Unable to determine current scopes)" |
| 161 | + fi |
| 162 | + echo "" |
| 163 | + echo "📝 To fix this issue, run:" |
| 164 | + echo " gh auth refresh -h github.com -s read:project" |
| 165 | + echo "" |
| 166 | + echo "ℹ️ If using a PAT, go update the permissions to include the 'read:project' scope." |
| 167 | + exit 1 |
| 168 | + elif echo "$response" | grep -q "Could not resolve to a ProjectV2"; then |
149 | 169 | echo "❌ Error: Project #$project_number not found in organization '$org'" |
150 | 170 | echo "Make sure:" |
151 | 171 | echo "- The project number is correct" |
|
0 commit comments