Integration and Usage
Initialization
Add the following in the go.mod file.
require ( ... github.com/ontology-tech/ontlogin-sdk-go latest)Add API Methods
Import the methods in the main.go file.
requestChallenge: Returns the challenge from the serversubmitChallenge: Passes the signed challenge and VP (if requested by the server)
package main
import (
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
"ontlogin-sample/auth"
"ontlogin-sample/service"
)Initialize the service, perform cross-origin resource sharing checks and define API methods.
Import and Use service.go
service.goHandle API requests using service.go
Handle VP
Use the following to extract VC from VP in form of JSON text.
Since the form of VC varies according to the server's request, only JSON is supported here. The server can parse the VC into the per-defined form.
Last updated