I trying to deploy to railway using Azure Pipeline but unable to authorize
dxred-yagnik
HOBBYOP

a month ago

Even testing using postman getting below. I tried to generate token so many times but same error.

POST /graphql/v2 HTTP/1.1

Host: backboard.railway.com

Content-Type: application/json

Authorization: Bearer xxxxxxxx-de27-4445-a503-2abf5bbxxxxx

Content-Length: 39

{"query":"query { me { name email } }"}

{

"errors": [

{

"message": "Not Authorized",

"locations": [

{

"line": 1,

"column": 9

}

],

"path": [

"me"

],

"extensions": {

"code": "INTERNAL_SERVER_ERROR"

},

"traceId": "2552335303157604505"

}

],

"data": null

}

please help to fix asap as its blocker to deployment

Solved

5 Replies

Railway
BOT

a month ago

The query { me { name email } } query only works with account tokens, not workspace or project tokens. If you're using a project token, it also requires the Project-Access-Token header instead of Authorization: Bearer. You can create an account token (by selecting "No workspace") at railway.com/account/tokens and verify it works with the me query before integrating into your Azure Pipeline.


Status changed to Awaiting User Response Railway about 1 month ago


dxred-yagnik
HOBBYOP

a month ago

account token works and return

{

"data": {

"me": {

"name": "Yagnik Jadav",

"email": "yagnik.jadav@dxred.com"

}

}

}

But still pipeline return below error

Token length: 36

Unauthorized. Please check that your RAILWAY_TOKEN is valid and has access to the resource you're trying to use.

whoami failed

Unauthorized. Please check that your RAILWAY_TOKEN is valid and has access to the resource you're trying to use.

Invalid RAILWAY_TOKEN. Please check that it is valid and has access to the resource you're trying to use.

below is pipeline code

- script: |

npm install -g @railway/cli@latest

railway --version

displayName: 'Install Railway CLI'

- script: |

echo "Token: $RAILWAY_TOKEN"

echo "Token length: ${#RAILWAY_TOKEN}"

railway whoami || echo "whoami failed"

railway link --project $RAILWAY_PROJECT_ID --environment develop

railway up --service $RAILWAY_SERVICE_ID --ci

displayName: 'Deploy to Railway'

env:

RAILWAY_TOKEN: $(RAILWAY_TOKEN)

RAILWAY_PROJECT_ID: $(RAILWAY_PROJECT_ID)

RAILWAY_SERVICE_ID: $(RAILWAY_SERVICE_ID)


Status changed to Awaiting Railway Response Railway about 1 month ago


Railway
BOT

a month ago

Our CLI uses two different environment variables for tokens: RAILWAY_TOKEN for project tokens and RAILWAY_API_TOKEN for account/workspace tokens (docs). Your pipeline is setting an account token as RAILWAY_TOKEN, which won't work. You have two options: either set your account token as RAILWAY_API_TOKEN instead, or use a project token (generated from your service's settings) with RAILWAY_TOKEN and remove the railway whoami and railway link commands since project tokens are already scoped to a specific project and environment and only support railway up, railway redeploy, and railway logs.


Status changed to Awaiting User Response Railway about 1 month ago


dxred-yagnik
HOBBYOP

a month ago

It worked, thanks.


Status changed to Awaiting Railway Response Railway about 1 month ago


Status changed to Solved dxred-yagnik about 1 month ago


dxred-yagnik
HOBBYOP

a month ago

what a great quick revert, never expected prompt response. Appreciated.


Status changed to Awaiting Railway Response Railway about 1 month ago


Status changed to Solved dxred-yagnik about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...