Plugin for the Credentials framework that authenticate using GitHub

Mac OS X Linux Apache 2


Plugin for Kitura-Credentials framework that authenticates using the GitHub web login with OAuth.

Table of Contents

Swift version

The latest version of Kitura-CredentialsGitHub requires Swift 3.0. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

Example of GitHub web login

First create an instance of CredentialsGitHub plugin and register it with Credentials framework: “`swift import Credentials import CredentialsGitHub

let credentials = Credentials() let gitCredentials = CredentialsGitHub(clientId: gitClientId, clientSecret: gitClientSecret, callbackUrl: serverUrl + /login/github/callback, userAgent: my-kitura-app) credentials.register(gitCredentials) ” **Where:** - *gitClientId* is the Client ID of your app in your GitHub Developer applications - *gitClientSecret* is the Client Secret of your app in your GitHub Developer applications - *userAgent* is an optional argument that passes along a User-Agent of your choice on API calls against GitHub. By default,Kitura-CredentialsGitHub` is set as the User-Agent. User-Agent is required when invoking GitHub APIs.

Note: The callbackUrl parameter above is used to tell the GitHub web login page where the user’s browser should be redirected when the login is successful. It should be a URL handled by the server you are writing. Specify where to redirect non-authenticated requests: swift credentials.options["failureRedirect"] = "/login/github"

Connect credentials middleware to requests to /private:

router.all("/private", middleware: credentials)
router.get("/private/data", handler: { request, response, next in

And call authenticate to login with GitHub and to handle the redirect (callback) from the GitHub login web page after a successful login:

handler: credentials.authenticate(

handler: credentials.authenticate(


This library is licensed under Apache 2.0. Full license text is available in LICENSE.