Added retrieving API token from a local property or environment variable.
This commit is contained in:
parent
87357f5127
commit
e857d3d3aa
5 changed files with 139 additions and 39 deletions
42
README.md
42
README.md
|
@ -17,7 +17,7 @@ poster.addPin("http://www.example.com/foo", "This is a test")
|
|||
poster.deletePin("http:///www.example.com/bar")
|
||||
|
||||
```
|
||||
[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt#L203)
|
||||
[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt#L219)
|
||||
|
||||
### Java
|
||||
```java
|
||||
|
@ -116,6 +116,46 @@ logger.setLevel(Level.FINE);
|
|||
|
||||
or using a logging properties file.
|
||||
|
||||
## API Authentication Token
|
||||
|
||||
The token can also be located in a [properties file](https://en.wikipedia.org/wiki/.properties) or environment variable.
|
||||
|
||||
### Local Property
|
||||
|
||||
For example, using the default `PINBOARD_API_TOKEN` key value from a `local.properties` file:
|
||||
|
||||
```ini
|
||||
# local.properties
|
||||
PINBOARD_API_TOKEN=user\:TOKEN
|
||||
```
|
||||
|
||||
```kotlin
|
||||
val poster = PinboardPoster(Paths.get("local.properties"))
|
||||
```
|
||||
|
||||
To specify your own key:
|
||||
|
||||
```ini
|
||||
# my.properties
|
||||
my.api.key=user\:TOKEN
|
||||
```
|
||||
|
||||
```kotlin
|
||||
val poster = PinboardPoster(Paths.get("my.properties"), "my.api.key")
|
||||
```
|
||||
|
||||
### Environment Variable
|
||||
|
||||
If no arguments are passed to the constructor, the `PINBOARD_API_TOKEN` environment variable will be used, if any.
|
||||
|
||||
```sh
|
||||
export PINBOARD_API_TOKEN="user:TOKEN"
|
||||
```
|
||||
|
||||
```kotlin
|
||||
val poster = PinboardPoster()
|
||||
```
|
||||
|
||||
## API End Point
|
||||
|
||||
The API end point is automatically configured to `https://api.pinboard.in/v1/`. Since Pinboard uses the `del.ico.us` API, the library could potentially be used with another compatible service. To configure the API end point, use:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue