Categorygithub.com/necrobits/grenzy-sdk-go
module
0.0.0-20230526054557-06075e978a9c
Repository: https://github.com/necrobits/grenzy-sdk-go.git
Documentation: pkg.go.dev

# README

GrenzyID SDK for Golang

You can use the SDK to integrate your Golang application with GrenzyID, using the PKCE flow.

The SDK can be used independently, or you can integrate it with your favorite web framework using the grenzysp package.

Currently support OpenID Connect (OIDC) only.

Getting started

Get the SDK

go get -u github.com/necrobits/grenzy-sdk-go

Create a new GrenzyID client

import (
    "github.com/necrobits/grenzy-sdk-go/grenzy"
)

//...

clientCfg := &grenzy.ClientConfig{
    ClientID:          "clientid",
    ClientSecret:      "clientsecret",
    GrenzyURL:        "http://localhost:3000",
    OidcRedirectURL:   "http://localhost:3001/callback",
}
grenzyClient := grenzy.NewClient(clientCfg)
// Call the InitOidc method to initialize the client.
// This method retrieves the OpenID configuration from the GrenzyID server.
err := grenzyClient.Init()

Supported frameworks

Echo

Create the support object

import (
    "github.com/necrobits/grenzy-sdk-go/grenzysp"
)
// ...
echoSp := grenzysp.NewEchoSupport(grenzyClient)

Handle the login request

router.GET("/login", echoSp.BuildLoginHandler([]string{"openid", "profile", "email"}))

Handle the callback request

router.GET("/callback", echoSp.BuildCallbackHandler(func(c echo.Context, tokenResponse *grenzy.TokenExchangeResponse) error {
    userinfo, err := echoSp.Client.GetUserInfo(tokenResponse.AccessToken)
    // ...
}))

Gin

Tbd.

License

MIT © Necrobits

# Packages

No description provided by the author
No description provided by the author
No description provided by the author