Crates.io | phabricator-oauth |
lib.rs | phabricator-oauth |
version | 0.1.8 |
source | src |
created_at | 2021-02-05 15:58:42.598383 |
updated_at | 2024-05-09 17:03:25.814065 |
description | Library for OAuth2 authentication on Phabricator |
homepage | |
repository | https://github.com/zryambus/phabricator-oauth |
max_upload_size | |
id | 351165 |
size | 8,181 |
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();