Skip to content

aethiopicuschan/touchid-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TouchID Go

License: MIT Go Reference Go Report Card CI

touchid-go is a Go library for Touch ID authentication on macOS. It provides a simple API and supports context.Context for managing timeouts and cancellations.

It is possible that it works on iOS as well, but it has not been confirmed.

Installation

go get -u github.com/aethiopicuschan/touchid-go

Example

package main

import (
	"context"
	"fmt"
	"os"
	"time"

	"github.com/aethiopicuschan/touchid-go"
)

func main() {
	// Wait for 5 seconds for the user to authenticate
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	// Authenticate with Touch ID
	ok, err := touchid.Authenticate(ctx, "Sample Text")
	if err != nil {
		if ctx.Err() == context.DeadlineExceeded {
			fmt.Println("Authentication timed out")
		} else {
			fmt.Println("Error:", err.Error())
		}
		os.Exit(1)
	}

	// Check the result
	if ok {
		fmt.Println("Authentication succeeded")
	} else {
		fmt.Println("Authentication failed")
		os.Exit(1)
	}
}

About

Go library for Touch ID authentication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages