Error: Unauthorized: could not retrieve site

I have a github action (source here) to push our docs to the netlify site we have (site id: 6ccfaa40-032b-46c8-a401-c9c5c6b0accc).

I am owner of a team in netlify (Open Health Imaging Foundation) . I have created personal access token in netlify and added that to github and i’m adding them

However, in the workflow i get the error

Can anyone help me please?

I tried the same credentials in the netlify cli locally and it works fine.
I have tried re-genrating the token again

Actually i figured out the error and the correct fix is this

  - name: Deploy to Netlify
        run: |
          cd packages/docs
          netlify deploy --dir=build --prod
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

However, everytime i need to click on the link to authorize, how can i avoid this?

The same thing started happening to us yesterday as well. We are looking for a solution but haven’t found one yet.

1 Like

I cannot reproduce this: add cli · hrishikesh-k/zd-360882@10f3da6, workflow: zd-360882/.github/workflows/deploy.yml at main · hrishikesh-k/zd-360882

@hrishikesh, do you know what the possible issues could be? I have all the keys set up in GitHub, but it still asks to click on the link. When exactly does that link request appear for the user?

It appears when we don’t detect either of:

  • NETLIFY_AUTH_TOKEN environment variable
  • of the --auth flag

Since I cannot reproduce this and it’s affecting just the two reports here, I’m inclined to believe that somehow your auth token is not working or not correctly stored in the repo.

Have you tried recreating a new token? Or maybe try logging the variable somewhere to see if you can actually access it?