The new wave of github apps
Github apps on the rise
Github apps on the rise
Now with a few lines of code we can create a flask application to install our new Github Application. (Yes, this is all the code you need)
# app.py
from flask import Flask, request, jsonify
app = Flask(__name__)
GITHUB_INSTALL_URL = "https://github.com/apps/<Github-App-Name>/installations/new"
@app.route('/')
def index():
return f"<h1>Github Apps with Flask</h1></br> <a href='{GITHUB_INSTALL_URL}'>Install app</a>"
if __name__ == "__main__":
app.run()
Using a Github app is the preferred way integrate with Github. By creating a Github app you can give your users more granular control of what you have access to. By transitioning Conveyor.dev to use a Github app the level of permissions that must be granted are much lower. For instance, when using an Oauth App with Github if you wanted to be able to read the contents of a repository you would need to ask for Read/Write permissions to every public and private repo for that user. With a Github App you can get Read-Only permission to select repositories.
To get started head over to the Github Apps page and click the New Github App button.
To register a Github app fill out a few details:
Now start your flask server with the flask run
command and navigate to
http://localhost:5000
and click on the Install app link to install the
Github application to your account
With that you now have your Github App installed on your account with access to the repo(s) that you selected.
Receiving webhook events and authenticating will be covered in the future.
$ ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/masecondgit_rsa
Create a file at ~/.ssh/config
# create the first host to use your original key as default
Host github.com
IdentityFile ~/.ssh/id_rsa
HostName github.com
User mikeabrahamsen
# create a second host to use with the second github account
Host github.com-secondgit
HostName github.com
User mikeabrahamsen
IdentityFile ~/.ssh/masecondgit_rsa
Now to use the second account with the ssh key use the following when you clone:
# notice the '-secondgit' before the ':'
git clone git@github.com-secondgit:mikeabrahamsen/dotfiles.git
If you want to add this to an already created repo
git remote add origin git@github.com-secondgit:mikeabrahamsen/dotfiles.git