How to Authenticate GitHub with OAuth

token
oauth
personal
access
github

#1

#Summary

Just released a new step: authenticate-with-github-oauth, so if you have two-factor authentication, private submodules, etc. then using a Personal Access Token would be the best bet.

To make this possible globally, this step writes GitHub OAuth configs to the ~/.netrc file, so every single network call pointing to github.com or api.github.com hosts will be accessed with the given Personal Access Token and the GitHub username.

#Add the step to your workflow

This step should be before any other git step in your workflow. Can go straight to the first place. :ok_hand:

An example bitrise.yml:

---
format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

workflows:
  primary:
    steps:
    - authenticate-with-github-oauth:
        inputs:
        - username: myusername
        - access_token: myaccesstoken
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
    before_run: 
    after_run: 

#Configuring the step

  • GitHub username: your GitHub username
  • Personal Access Token: your Personal Access Token

#Get a GitHub Personal Access Token

  1. Login to yout GitHub account
  2. In the upper-right corner of any page, click your profile photo, then click Settings.
  3. In the left sidebar, click Personal access tokens.
  4. Click Generate new token.
  5. Give your token a descriptive name.
  6. Select the scopes, or permissions, you’d like to grant this token.
  7. Click Generate token.

Happy Coding! :tada::rocket:


#2

@tamaspapik What if I want to auth both with e.g. GitHub and Bitbucket? :wink:

Also: do I need the Activate SSH Key step?


#3

@viktorbenei Could you add this to the Web interface which creates new app workflow?


#4

You can use both easily.
Activate SSH Key step is not required, however you will need to use git urls starting with https://...