Skip to content

nhatthm/moneyloverkeychain

Repository files navigation

Keychain Storage for MoneyLover API Client

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

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

Prerequisites

  • Go >= 1.16

Install

go get github.com/nhatthm/moneyloverkeychain

Usage

moneyloverapi.CredentialsProvider

Examples

Build moneyloverapi.Client:

package mypackage

import (
	"github.com/nhatthm/moneyloverapi"
	"github.com/nhatthm/moneyloverkeychain/credentials"
)

func buildClient(username string) (*moneyloverapi.Client, error) {
	c := moneyloverapi.NewClient(
		credentials.WithCredentialsProvider(username),
	)

	return c, nil
}

Persist credentials in system keyring:

package mypackage

import (
	"github.com/nhatthm/moneyloverkeychain/credentials"
)

func persist(username, password string) error {
	c := credentials.New(username)

	return c.Update(password)
}

auth.TokenStorage

package mypackage

import (
	"github.com/nhatthm/moneyloverapi"
	"github.com/nhatthm/moneyloverkeychain/token"
)

func buildClient() *moneyloverapi.Client {
	return moneyloverapi.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