From ea8a162f637a61823be2fd54cc3050bb6149e790 Mon Sep 17 00:00:00 2001 From: Jean-Tiare Le Bigot Date: Fri, 18 Mar 2016 17:04:35 +0100 Subject: [PATCH] improve README examples from review Signed-off-by: Jean-Tiare Le Bigot --- README.md | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 980c581a..46852bc1 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ 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: @@ -116,7 +116,20 @@ The consumer key has two types of restriction: * 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 @@ -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 @@ -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 @@ -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