tokkit
is a simple(even simplistic) token toolkit for OAUTH2 authorization
targetting service to service authorization.
tokkit is available on crates.io.
The documentation is available online.
tokkit
contains a module token_info
for protected resources to verify access tokens.
rust,no_run
use tokkit::*;
use tokkit::token_info::*;
let builder = RemoteTokenInfoServiceBuilder::google_v3();
let service = builder.build().unwrap();
let token = AccessToken::new("<token>");
let tokeninfo = service.introspect(&token).unwrap();
tokkit
can manage and automatically update your access tokens if you
are a client and want to access a resource owners resources.
Currently tokkit
only supports the
Resource Owner Password Credentials Grant
which should only be used if the resource owner can really trust the client.
```rust,norun use tokkit::*; use tokkit::tokenmanager::; use tokkit::token_manager::token_provider::; use tokkit::tokenmanager::tokenprovider::credentials::*;
let credentialsprovider = SplitFileCredentialsProvider::withdefaultparsersfrom_env() .unwrap();
let tokenprovider = ResourceOwnerPasswordCredentialsGrantProvider ::fromenvwithcredentialsprovider(credentialsprovider) .unwrap();
let tokengroup = ManagedTokenGroupBuilder::singletoken( "mytokenidentifier", vec![Scope::new("readmydiary")], token_provider) .build() .unwrap();
let tokensource = AccessTokenManager::start(vec![tokengroup]).unwrap();
let accesstoken = tokensource.getaccesstoken(&"mytokenidentifier").unwrap(); ```
tokkit is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0). Copyright (c) 2017 Christian Douven