Michael Abrahamsen

Sep 24, 2019

Sep 21, 2019

Integrate

Create a link in a flask app to install your application

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()

Create a Github app to integrate with Github

demo

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:

  • App name
  • Homepage URL
  • User authorization callback URL
  • Webhook URL (we will update this in the next part of the series)

Github App Main
Content

Install your Github application

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

demo

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.

Mar 29, 2017

Creating Multiple SSH Key Settings For Github Accounts

Create a new ssh key for the second account

$ ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/masecondgit_rsa

Create an ssh config

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
posted at 18:10  ·   ·  git  github  ssh