The latest version of Kitura-CredentialsGitHub requires Swift 4.0 or newer. 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
This guide assumes basic knowledge of Kitura app routing.
First, set up the session middleware:
import KituraSession
router.all(middleware: Session(secret: "Very very secret..."))
Create an instance of CredentialsGitHub plugin and register it with Credentials framework:
gitClientId is the Client ID of your app in your GitHub Developer application settings
gitClientSecret is the Client Secret of your app in your GitHub Developer application settings
callbackUrl 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.
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.
options is an optional dictionary ([String: Any]); the allowable options are listed in CredentialsGitHubOptions
Next, specify where to redirect non-authenticated requests:
Kitura-CredentialsGitHub
Plugin for the Credentials framework that authenticate using GitHub
Summary
Plugin for Kitura-Credentials framework that authenticates using the GitHub web login with OAuth2 API.
Table of Contents
Swift version
The latest version of Kitura-CredentialsGitHub requires Swift 4.0 or newer. 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
This guide assumes basic knowledge of
Kitura
app routing.First, set up the session middleware:
Create an instance of
CredentialsGitHub
plugin and register it withCredentials
framework:Where:
Kitura-CredentialsGitHub
is set as the User-Agent. User-Agent is required when invoking GitHub APIs.[String: Any]
); the allowable options are listed inCredentialsGitHubOptions
Next, specify where to redirect non-authenticated requests:
Connect
credentials
middleware to handle requests to a protected path on the server, such as/private
:And call
authenticate
to login with GitHub and to handle the redirect (callback) from the GitHub login web page after a successful login:License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.