This library is derived from yup-oauth2. Many of the doc comments are still refering to the original library.
This library can be used to acquire oauth2.0 authentication for services.
For your application to use this library, you will have to obtain an application id and secret by following this guide (for Google services) respectively the documentation of the API provider you want to connect to.
Service account "flow"
When using service account credentials, no user interaction is required. The access token
can be obtained automatically using the private key of the client (which you can download
from the API provider). See service_account for an example on how to use service
account credentials. See
developers.google.com
for a detailed description of the protocol. This crate implements OAuth for Service Accounts
based on the Google APIs; it may or may not work with other providers.
The returned Token will be stored in memory in order to authorize future
API requests to the same scopes. The tokens can optionally be persisted to
disk by using persist_tokens_to_disk when creating the authenticator.
The following example, shows the basics of using this crate:
use parse_service_key;
use AuthenticatorBuilder as AB;
static SERVICE_CREDENTIALS:& = include_bytes!;
// The clientsecret file contains JSON like `{"type":"service_account", "project_id":"my-super-project", ...}`
async