I am trying to setup a local drone server to be used as our CI environment. Our source code is managed by Github.
First, I create an oauth application on Github and get the client_id and client_secret.
Then install docker and drone, after that I did below configuration on /etc/drone/dronerc
REMOTE_DRIVER=github
REMOTE_CONFIG=https://github.com?client_id=XXXXXX&client_secret=XXXXXX
DATABASE_DRIVER=sqlite3
DATABASE_CONFIG=/var/lib/drone/drone.sqlite
Then I run below command to start drone docker container:
sudo docker run \
--volume /var/lib/drone:/var/lib/drone \
--volume /var/run/docker.sock:/var/run/docker.sock \
--env-file /etc/drone/dronerc \
--restart=always \
--publish=80:8000 \
--detach=true \
--name=drone \
drone/drone:0.4
I access the drone link on the browser, I can see a login button. As shown below.
When I click on the login button, my callback url is notified with below error message:
error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.
Below is the server code for the Github callback url:
get '/oauth/authorize' do
# get temporary GitHub code...
session_code = request.env['rack.request.query_hash']['code']
# ... and POST it back to GitHub
result = RestClient.post('https://github.com/login/oauth/access_token',
{:client_id => CLIENT_ID,
:client_secret => CLIENT_SECRET,
:code => session_code},
:accept => :json)
# extract the token and granted scopes
access_token = JSON.parse(result)['access_token']
redirect 'http://10.0.0.24/'
end
In the last line of the above code, the redirect address is drone server address. I may be do a wrong thing on the OAuth authentication part but I don't know how to do that in a correct way. Does anyone know how to implement that part to allow drone to get access on my Github account?
Thanks