#oauth2 #phabricator #oauth

phabricator-oauth

Library for OAuth2 authentication on Phabricator

9 releases

new 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

#328 in Authentication

Download history 16/week @ 2024-02-26 8/week @ 2024-04-01 112/week @ 2024-05-06

112 downloads per month

MIT license

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–19MB
~305K SLoC