tiny_google_oidc
Tiny library for Google's OpenID Connect.
Implementation in server flow
google document
Feature
- Generate a CSRF Token
- Generate an authentication request URL (code) for Google
- Verify CSRF token and retrieve id_token
- Exchange code for id_token (using reqwest)
- Decode id_token (Base64URLDecode) to get user information
- Refresh access token using refresh token (using reqwest)
- Revoke access/refresh token (using reqwest)
Caution
This library is designed for direct communication with Google over HTTPS.
It does not validate the id_token when converting it to a JWT,
so the id_token cannot be passed to other components of your app.
See document
Example
Here's hou you can use this library with the axum framework.
1. Create Config
First, We create Config struct the is including Client ID, Secrets, etc...
let oidc_cfg = new
.auth_endpoint
.client_id
.client_secret
.token_endpoint
.redirect_uri
.build;
2. Login Handler
Here's an example handler to start the login flow.
async
3. Callback Handler
Here’s an example of a callback handler for when the provider (like Google) redirects back.
async
Of course, you can use this library with other framework as well!
See example for more detailes.
Contributing
We are currently working on the official contribution guidelines.
However, we welcome bug reports, feature requests, and questions via GitHub Issues!
Your feedback is very much appreciated and will help make this library better for everyone.
Thank you for your interest and support!
License
tiny_google_oidc is provided under the MIT license.See LICENSE