Skip to content

Keychain Storage for N26 API Client

License

Notifications You must be signed in to change notification settings

nhatthm/n26keychain

Repository files navigation

Keychain Storage for N26 API Client

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

n26keychain uses system keyring as a storage for persisting/getting credentials and token. It supports OS X, Linux (dbus) and Windows.

Prerequisites

  • Go >= 1.17

Install

go get github.com/nhatthm/n26keychain

Usage

n26api.CredentialsProvider

Examples

Build n26api.Client:

package mypackage

import (
	"github.com/google/uuid"
	"github.com/nhatthm/n26api"
	"github.com/nhatthm/n26keychain/credentials"
)

func buildClient() (*n26api.Client, error) {
	deviceID := uuid.New()

	c := n26api.NewClient(
		n26api.WithDeviceID(deviceID),
		credentials.WithCredentialsProvider(),
	)

	return c, nil
}

Persist credentials in system keyring:

package mypackage

import (
	"github.com/google/uuid"
	"github.com/nhatthm/n26keychain/credentials"
)

func persist(deviceID uuid.UUID, username, password string) error {
	c := credentials.New(deviceID)
	
	return c.Update(username, password)
}

auth.TokenStorage

package mypackage

import (
	"github.com/nhatthm/n26api"
	"github.com/nhatthm/n26keychain/token"
)

func buildClient() *n26api.Client {
	return n26api.NewClient(
		token.WithTokenStorage(),
	)
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this