9 releases
0.1.8 | May 9, 2024 |
---|---|
0.1.7 | Dec 24, 2021 |
0.1.6 | Jul 30, 2021 |
0.1.5 | May 7, 2021 |
0.1.4 | Feb 25, 2021 |
#238 in Authentication
515 downloads per month
8KB
109 lines
Phabricator-OAuth
Library for OAuth2 authentication on Phabricator
Example
use phabricator_oauth::*;
...
let phid = String::from("PHABRICATOR_ID");
let secret = String::from("PHABRICATOR_SECRET");
let redirect_url = String::from("https://yourservice.com/auth"); // Exactly like in oauth settings on phabricator
let phabricator_url = String::from("https://phabricator.yourdomain.com");
let client = PhabOAuthClient::new(phid, secret, redirect_url, phabricator_url).unwrap();
...
// Getting URL and CSRF token for authentication on the phabricator
let (redirect_url, _csrf_token) = client.get_auth_url().unwrap();
...
// Getting OAuth token. Code will be in GET parameters in your /auth handler
let token = client.get_token(code).await.unwrap();
let access_token = token.access_token();
...
// Getting current user info
let user = client.get_user(access_token).await.unwrap();
Dependencies
~6–18MB
~260K SLoC