| guard_github | R Documentation |
This guard requests you to log in with GitHub and authenticates yourself
through their service. Your server must be registered and have a valid client
ID and client secret for this to work. Register an application at
https://github.com/settings/applications/new. If you want to limit access
to only select users you should make sure to provide a validate function
that checks the userinfo against a whitelist.
guard_github(redirect_url, client_id, client_secret, ..., name = "github")
redirect_url |
The URL the authorization server should redirect to following a successful authorization. Must be equivalent to one provided when registering your application |
client_id |
The ID issued by the authorization server when registering your application |
client_secret |
The secret issued by the authorization server when registering your application. Do NOT store this in plain text |
... |
Arguments passed on to
|
name |
The name of the guard |
A GuardOAuth2 object
guard_github() automatically adds user information according to the
description in guard_oauth2(). It sets the provider field to "github".
Further, extracts information from the https://api.github.com/user endpoint
and maps the information accordingly:
id -> id
name -> name_display
login -> name_user
email -> emails
avatar_url -> photos
It also sets the .raw field to the full list of information returned from
github.
Documentation for GitHub's OAuth 2 flow
github <- guard_github(
redirect_url = "https://example.com/auth",
client_id = "MY_APP_ID",
client_secret = "SUCHASECRET"
)
# Add it to a fireproof plugin
fp <- Fireproof$new()
fp$add_guard(github, "github_auth")
# Use it in an endpoint
fp$add_auth("get", "/*", github_auth)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.