Skip to content

About

Identisure API client for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Identisure Go Client

pkg.go.dev MIT license

API client for the Identisure REST API.

Documentation: pkg.go.dev/github.com/identisure/api-client-go

Requirements

Go 1.21 or later.

Supported providers

  • BankID SE: auth, sign, phone auth and sign, QR verify, age verification
  • BankID NO: auth, backchannel auth, sign, age verification
  • Freja eID: auth, backchannel auth, sign, backchannel sign, age verification
  • MitID: auth, backchannel auth, sign, age verification
  • FTN (Finnish Trust Network): auth, age verification
  • Vipps MobilePay: auth, backchannel auth
  • Documents: upload and download documents for signing

Installation

go get github.com/identisure/api-client-go

Usage

package main

import (
    "context"
    "fmt"
    "time"

    identisure "github.com/identisure/api-client-go"
)

func main() {
    client := identisure.NewClientBuilder("client_id", "client_secret").
        Environment(identisure.Staging).
        Build()

    ctx := context.Background()

    session, err := client.BankIdSe().Auth(ctx, identisure.BankIdSeAuthRequest{})
    if err != nil {
        panic(err)
    }

    pending := session.(*identisure.BankIdSePending)
    fmt.Println("Session ID:", pending.Id)

    pollCtx, cancel := context.WithTimeout(ctx, 5*time.Minute)
    defer cancel()

    result, err := client.BankIdSe().WaitForAuth(pollCtx, pending.Id, identisure.PollOptions{})
    if err != nil {
        panic(err)
    }

    switch r := result.(type) {
    case *identisure.BankIdSeCompleted:
        fmt.Println("Authenticated:", r.Name, r.Ssn)
    case *identisure.BankIdSeFailed:
        fmt.Println("Failed:", r.Error)
    }
}

Verifying callbacks

valid := identisure.VerifyCallbackSignature(rawBody, r.Header.Get("X-Signature-SHA256"), hmacSecret)

Development

Test fixtures live in a submodule. Clone with --recurse-submodules, or run git submodule update --init in an existing clone.

Prerequisites

Build

go build ./...

Test

go test ./...

Vet

go vet ./...

Release

Set the version in client.go and document.go and commit. Then push a tag:

git tag v0.1.0
git push origin v0.1.0

The release workflow checks that the tag matches the version, runs CI, fetches the version through the Go module proxy and creates a GitHub release.

Other languages

C#, Dart, TypeScript/JavaScript, Java/Kotlin, PHP, Python, Ruby, Rust, Swift

About

Identisure API client for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages