danielgtaylor / danielgtaylor/huma
Add clientId for OAuth 2.0 in code and redeem OAuth 2.0 bearer token through Swagger UI or Stoplight UI
- Dominant language
- Go
- Stars
- 4.4k
- Forks
- 285
- Avg merge
- 40m
- Merged PRs (30d)
- 1
Description
Is there a possibility to define the client_id directly in the code, so I don't have to add it manually in the Swagger UI?
And I'm not sure about this, but I thought it would be nice if I could redeem a bearer token from my external OAuth2.0 provider ([Zitadel](https://github.com/zitadel/zitadel)) directly in the Swagger UI (or better, Stoplight). So I want to have an authorize button, that I can press, and I'll be redirected to my OAuth2.0 login page, and then be redirected back to my Swagger UI (or Stoplight), which stores the token for the requests. (I'm not sure if this also works with the PKCE workflow, but I know it works in Spring Boot with the password flow.) Is this possible yet and do you have an example for this?
(The OpenAPI documentation works, but how do I redeem a token?)
```go
humaConfig.Components.SecuritySchemes = map[string]*huma.SecurityScheme{
"MyApp": {
Type: "oauth2",
Flows: &huma.OAuthFlows{
AuthorizationCode: &huma.OAuthFlow{
AuthorizationURL: "https://zitadel.domain.com/oauth/v2/authorize",
TokenURL: "https://zitadel.domain.com/oauth/v2/token",
RefreshURL: "https://zitadel.domain.com/oauth/v2/token",
Scopes: map[string]string{
"openid": "",
"profile": "",
"email": "",
"offline_access": "",
},
},
},
},
}
router := gin.Default()
api := humagin.New(router, humaConfig)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.