https://github.com/nhatthm/n26keychain
Keychain Storage for N26 API Client
https://github.com/nhatthm/n26keychain
go golang keychain keyring n26
Last synced: 5 months ago
JSON representation
Keychain Storage for N26 API Client
- Host: GitHub
- URL: https://github.com/nhatthm/n26keychain
- Owner: nhatthm
- License: mit
- Created: 2021-04-05T18:14:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-25T00:41:52.000Z (over 1 year ago)
- Last Synced: 2025-09-11T22:48:46.660Z (10 months ago)
- Topics: go, golang, keychain, keyring, n26
- Language: Go
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Keychain Storage for N26 API Client
[](https://github.com/nhatthm/n26keychain/releases/latest)
[](https://github.com/nhatthm/n26keychain/actions/workflows/test.yaml)
[](https://codecov.io/gh/nhatthm/n26keychain)
[](https://goreportcard.com/report/github.com/nhatthm/httpmock)
[](https://pkg.go.dev/github.com/nhatthm/n26keychain)
[](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)
`n26keychain` uses [system keyring](https://github.com/zalando/go-keyring#go-keyring-library) as a storage for persisting/getting credentials and token. It supports OS X, Linux
(dbus) and Windows.
## Prerequisites
- `Go >= 1.17`
## Install
```bash
go get github.com/nhatthm/n26keychain
```
## Usage
### `n26api.CredentialsProvider`
**Examples**
Build `n26api.Client`:
```go
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:
```go
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`
```go
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
[](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)
or scan this