n26keychain

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 8 Imported by: 0

README

Keychain Storage for N26 API Client

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.14

Install

go get github.com/nhatthm/n26keychain

Usage

n26api.CredentialsProvider

Examples

Build n26api.Client:

package mypackage

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

func buildClient() (*n26api.Client, error) {
	cred, err := n26keychain.Credentials()
	if err != nil {
		return nil, err
	}

	c := n26api.NewClient(
		n26api.WithCredentialsProvider(cred),
	)

	return c, nil
}

Persist credentials in system keyring:

package mypackage

import "github.com/nhatthm/n26keychain"

func persist(username, password string) error {
	return n26keychain.PersistCredentials(username, password)
}
auth.TokenStorage
package mypackage

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

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

Documentation

Overview

Package n26keychain provides keychain as a storage for credentials and token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Credentials

func Credentials() (n26api.CredentialsProvider, error)

Credentials returns credentials from keychain.

func DeleteCredentials

func DeleteCredentials() error

DeleteCredentials deletes the credentials in keychain.

func PersistCredentials

func PersistCredentials(username, password string) error

PersistCredentials persists the credentials to keychain.

func TokenStorage

func TokenStorage() auth.TokenStorage

TokenStorage returns keychain as a token storage.

func WithTokenStorage added in v0.1.1

func WithTokenStorage() n26api.Option

WithTokenStorage sets keychain as a token storage for n26 client.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL