phabricator-oauth

Crates.iophabricator-oauth
lib.rsphabricator-oauth
version0.1.8
sourcesrc
created_at2021-02-05 15:58:42.598383
updated_at2024-05-09 17:03:25.814065
descriptionLibrary for OAuth2 authentication on Phabricator
homepage
repositoryhttps://github.com/zryambus/phabricator-oauth
max_upload_size
id351165
size8,181
Ilya Volchenkov (zryambus)

documentation

README

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();
Commit count: 9

cargo fmt