Platform

Sign Up With GitHub

8 min

Sign In with Github Tutorial

Introduction

Sign In with Github enables users to sign in to Apps using their Github accounts.

Prerequisites

To complete this tutorial, you will need:

1 - Create a New Back4App App

First of all, it’s necessary to make sure that you have an existing app created at Back4App. However, if you are a new user, you can check this tutorial to learn how to create one.

2 - Create a new Github App

Create a new Github Application by going to Applications/New Fill up the Application name, your Homepage URL, a quick Description and your Authorization callback URL`

Document image


Then click Register Application. You should then see your App Secret and Client Secret

Document image


3 - Retrieve your Code

Visit the following URL, changing the values for CLIENT_ID for the one you created.

https://github.com/login/oauth/authorize scope=user:email&client_id=CLIENT_ID

Log in with your GitHub account:

Document image


and the redirected website will have your code in the URL:

Document image


Copy the Code part of the URL only and run the following CURL command replacing the values YOUR_CODE, YOUR_CLIENT_ID, and YOUR_CLIENT_SECRET for the values of your application

Curl


Run it and you should retrieve your access token:

Document image


REMEMBER: the code can be used only once. If you get an error or don’t use your token, you must re-generate your Code to be able to run it again.

4 - Start the development

Now that the Sign In with Github is configured, you can start the development process. The format for AUTHDATA is:

JSON


Here is the method for the iOS SDK:

Swift


And here for the Android SDK:

Java