The hubic mix task makes requests to the Hubic Api on the user’s behalf to get details
such as the referesh token and then generates a configuration which can copied and pasted into config.exs
.
The environment variables generated by the task are automatically save to a .env
file. It is best to ensure that this file is outside
version control.
Shell Input:
mix ovh \
--login=<username-ovh> \
--password=<password> \
--appdescription='Ovh Application for my app' \
--endpoint='ovh-eu' \
--apiversion='1.0' \
--redirecturi='http://localhost:4000/' \
--accessrules='get-[/*]::put-[/me,/cdn]::post-[/me,/cdn]::delete-[]' \
--appname='my_app'
--clientname='OvhClient'
login
: username/nic_handle for logging into OVH services. Note: must include -ovh
at the end of the string. password
: password for logging into OVH services. appname
: this should correspond to the otp_app
name in the elixir application. It also doubles as the application name
for the application in the OVH servers. clientname
:” This is the elixir client name. defaults to ExOvh
when the appname is exactly equal to ex_ovh
, otherwise defaults to OvhClient
. clientname
corresponds to the name of the client. So for example, if appname is 'my_app'
and clientname is
'Client'
then the config file will be config :my_app, MyApp.Client
. Also, the client in application code can be referred
to as MyApp.Client.function_name
. appdescription
: A description for the application saved to OVH. endpoint
: OVH endpoint to be used. May vary depending on the OVH service. See ExOvh.Ovh.Defaults
. apiversion
: version of the api to use. Only one version available currently. redirecturi
: redirect url for oauth authentication. Should be https. accessrules
: restrictions can be added to the access rules. In this example, get
requests to all endpoints are allowed,
put
and post
requests to /me
and /cdn
and delete
requests are forbidden. Shell Output:
config :my_app, MyApp.OvhClient,
ovh: [
application_key: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_KEY"),
application_secret: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_SECRET"),
consumer_key: System.get_env("MY_APP_OVH_CLIENT_CONSUMER_KEY"),
endpoint: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
api_version: System.get_env("MY_APP_OVH_CLIENT_API_VERSION") || "1.0"
]
Terms explained:
MY_APP_OVH_CLIENT_APPLICATION_KEY
: The system environment variable name for the application key.
MY_APP_OVH_CLIENT_APPLICATION_SECRET
: The system environment variable name for the application secret.
MY_APP_OVH_CLIENT_CONSUMER_KEY
: The system environment variable name for the consumer key.
MY_APP_OVH_CLIENT_ENDPOINT
: The system environment variable name for the ovh endpoint.
MY_APP_OVH_CLIENT_API_VERSION
: The system environment variable name for the api version.
Copy the configuration outputted by the commandline to config.exs
.
The enviroment variables are saved to a file called .env
automatically by the mix task.
Do not add the .env
file to version control. Add the variables to the system environment
by running the command or some other commands as appropriate to the deployment method.
source .env
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
# Mix Task (Advanced)
## Generate client config
The hubic mix task makes requests to the Hubic Api on the user's behalf to get details
such as the referesh token and then generates a configuration which can copied and pasted into `config.exs`.
The environment variables generated by the task are automatically save to a `.env` file. It is best to ensure that this file is outside
version control.
**Shell Input:**
```shell
mix ovh \
--login=<username-ovh> \
--password=<password> \
--appdescription='Ovh Application for my app' \
--endpoint='ovh-eu' \
--apiversion='1.0' \
--redirecturi='http://localhost:4000/' \
--accessrules='get-[/*]::put-[/me,/cdn]::post-[/me,/cdn]::delete-[]' \
--appname='my_app'
--clientname='OvhClient'
```
- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
- `password`: password for logging into OVH services.
- `appname`: this should correspond to the `otp_app` name in the elixir application. It also doubles as the application name
for the application in the OVH servers.
- `clientname`:" This is the elixir client name. defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`. `clientname` corresponds to the name of the client. So for example, if appname is `'my_app'` and clientname is
`'Client'` then the config file will be `config :my_app, MyApp.Client`. Also, the client in application code can be referred
to as `MyApp.Client.function_name`.
- `appdescription`: A description for the application saved to OVH.
- `endpoint`: OVH endpoint to be used. May vary depending on the OVH service. See `ExOvh.Ovh.Defaults`.
- `apiversion`: version of the api to use. Only one version available currently.
- `redirecturi`: redirect url for oauth authentication. Should be https.
- `accessrules`: restrictions can be added to the access rules. In this example, `get` requests to all endpoints are allowed,
`put` and `post` requests to `/me` and `/cdn` and `delete` requests are forbidden.
**Shell Output:**
```elixir
config :my_app, MyApp.OvhClient,
ovh: [
application_key: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_KEY"),
application_secret: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_SECRET"),
consumer_key: System.get_env("MY_APP_OVH_CLIENT_CONSUMER_KEY"),
endpoint: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
api_version: System.get_env("MY_APP_OVH_CLIENT_API_VERSION") || "1.0"
]
```
Terms explained:
- `MY_APP_OVH_CLIENT_APPLICATION_KEY`: The system environment variable name for the application key.
- `MY_APP_OVH_CLIENT_APPLICATION_SECRET`: The system environment variable name for the application secret.
- `MY_APP_OVH_CLIENT_CONSUMER_KEY`: The system environment variable name for the consumer key.
- `MY_APP_OVH_CLIENT_ENDPOINT`: The system environment variable name for the ovh endpoint.
- `MY_APP_OVH_CLIENT_API_VERSION`: The system environment variable name for the api version.
- Copy the configuration outputted by the commandline to `config.exs`.
- The enviroment variables are saved to a file called `.env` automatically by the mix task.
**Do not add the `.env` file to version control.** Add the variables to the system environment
by running the command or some other commands as appropriate to the deployment method.
```shell
source .env
```