I am trying to sync repositories for a user created via the DRONE_USER_CREATE=username:[-gogs_username-],machine:false,admin:true,token:[-drone_token-] env var inside docker.
The user is created fine and I can verify this by making a get request Authorized with the token to /api/user.
For some reason the repositories refuse to sync until after I have manually logged in on the dashboard.
I tried sending a post with the login credentials to the login endpoint but that did not trigger an update for the login field on the user object returned.
I’m 100% sure I’m using correct authentication as it works on all other endpoints, tested in-code and via postman/browser.
For some reason the repositories refuse to sync until after I have manually logged in on the dashboard.
This is expected. The user account cannot interact with GitHub until you have gone through the oauth2 login process, which generates an oauth2 access token and refresh token, and authorizes Drone to access data on your behalf.
As you can tell by my env var I’m actually trying to run this with Gogs. The endpoint I’m trying to call is /api/user/repos?async=true and the debug simply says 401 unauthorised.
Is there any other endpoint I can hit to make the initial sync happen?
Under the hood this endpoint makes an API call to github/gitlab/gogs/gitea/bitbucket and requires an access token. This token is only available after a login. It is therefore required to login before you can invoke this endpoint.