Integration
To integrate Goiabada with your app, you'll need to explore your platform for an OAuth2/OpenID Connect client library. Many platforms provide such libraries for integration.
Javascript-only
The github repository of Goiabada has a browser-based javascript test client that you can use to test Goiabada. It uses the oauth4webapi library.
dotnet C# example
We also have a sample integration using dotnet C#.
The components of the solution are:
- A frontend web app application (ASP.NET razor pages) that requires the users to be authenticated in order to access an area of the site.
- A backend web api application (ASP.NET web api) responsible for serving weather forecasts. This API requires the permission
weather-forecast:read
.
The example uses OpenID Connect (authorization code flow with PKCE) to authenticate users on the frontend. Additionally, the client credentials flow is employed for the frontend server to obtain an access token for accessing the backend server.
Additionally, it implements secure logout (with encryption of the id token), and automatic refresh of the access tokens.
Please clone the repo to have access to the code. It is located here - https://github.com/leodip/goiabada/tree/main/test-integrations/dotnet6.
To run the example locally you need:
- An instance of Goiabada running. The example is configured to use
https://localhost:8080
as Goiabada's base URL, but you can change this inappsettings.json
if you want. - A client created in Goiabada called
dotnet6-integration-frontend
, with both Authorization code with PKCE and Client credentials flows enabled. - You must also register these two redirect URIs within the
dotnet6-integration-frontend
client:https://localhost:7096/signin-oidc
andhttps://localhost:7096/LogoutFrontend
. - In Goiabada, you need a resource with identifier
weather-forecast
. In this resource, you need a permission with identifierread
. - You must assign the permission
weather-forecast:read
to clientdotnet6-integration-frontend
. - You must copy the client secret of
dotnet6-integration-frontend
to the configuration fileGoiabada.TestIntegration.Frontend/appsettings.json
(OpenIDConnect:ClientSecret
andWeatherForecastService:ClientSecret
)
Finally, please make sure Goiabada is running, start up Goiabada.TestIntegration.Backend
application (web api) and start up Goiabada.TestIntegration.Frontend
application (razor pages). Then visit https://localhost:7096
in your browser.