OAuth2.0
An oauth 2.0 library that does not assume anything. The library can be used to produce OAuth 2.0 requests and parse token responses. It produces gleam http requests and takes in gleam http responses. Use whatever http client you prefer for either javascript or erlang. The library pulls in as few dependencies as possible to maintain compatibility with as many use cases as possible.
gleam add flwr_oauth2@1.3.0
import flwr_oauth2 as oauth2
import gleam/httpc
import gleam/uri
pub fn main() -> Nil {
let assert Ok(server) =
uri.parse(
"http://localhost:8080/realms/OAuth/protocol/openid-connect/token",
)
let token_request =
oauth2.ClientCredentialsGrantTokenRequest(
server,
oauth2.ClientSecretPost(
oauth2.ClientId("credentials-client"),
oauth2.Secret("client-secret"),
),
["openid"],
)
let assert Ok(req) = oauth2.to_http_request(token_request)
let res = httpc.send(req)
echo res
}
Further documentation can be found at https://hexdocs.pm/flwr_oauth2
Development
gleam run # Run the project
gleam test # Run the tests
Roadmap
OAuth 2.0 includes many different RFC which define and extend it. This package aims to implement the most common ones.