Skip to content

Commit

Permalink
improve README examples from review
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Tiare Le Bigot <jean-tiare.le-bigot@corp.ovh.com>
  • Loading branch information
Jean-Tiare Le Bigot committed Mar 18, 2016
1 parent a728d02 commit ea8a162
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,28 @@ credentials at once. See below.
### Use the API on behalf of a user

Visit [https://eu.api.ovh.com/createApp](https://eu.api.ovh.com/createApp) and create your app
You'll get an application key and an application secret. To use the API you'll need a consumer key.
You'll get an application key and an application secret. To use the API you'll need a consumer key.

The consumer key has two types of restriction:

* path: eg. only the ```GET``` method on ```/me```
* time: eg. expire in 1 day


Then, get a consumer key. Here's an example on how to generate one:
Then, get a consumer key. Here's an example on how to generate one.

First, create a 'ovh.conf' file in the current directory with the application key and
application secret. You can add the consumer key once generated. For alternate
configuration method, please see the [configuration section](#configuration).

```ini
[ovh-eu]
application_key=my_app_key
application_secret=my_application_secret
; consumer_key=my_consumer_key
```

Then, you may use a program like this example to create a consumer key for the application:

```go
package main
Expand Down Expand Up @@ -162,9 +175,21 @@ typically want to do this when writing automation scripts for a single projects.

If this case, you may want to directly go to https://eu.api.ovh.com/createToken/ to generate
the 3 tokens at once. Make sure to save them in one of the 'ovh.conf' configuration file.
Please see the [configuration section](#configuration).

``ovh.conf`` should look like:

```ini
[ovh-eu]
application_key=my_app_key
application_secret=my_application_secret
consumer_key=my_consumer_key
```

## Use the lib

These examples assume valid credentials are available in the [configuration](#configuration).

### GET

```go
Expand All @@ -177,11 +202,7 @@ import (
)

func main() {
ak := "your_app_key"
as := "your_app_secret"
ck := "your_consumer_key"

client, err := govh.NewClient("ovh-eu", ak, as, ck)
client, err := govh.NewEndpointClient("ovh-eu")
if err != nil {
fmt.Printf("Error: %q\n", err)
return
Expand Down Expand Up @@ -228,11 +249,7 @@ import (
)

func main() {
ak := "your_app_key"
as := "your_app_secret"
ck := "your_consumer_key"

client, err := govh.NewClient("ovh-eu", ak, as, ck)
client, err := govh.NewEndpointClient("ovh-eu")
if err != nil {
fmt.Printf("Error: %q\n", err)
return
Expand Down

0 comments on commit ea8a162

Please sign in to comment.