Models Management
Contains bash commands for the models.
Models Script
https://github.com/pingponglabs/mediamagic-platform/blob/main/scripts/models.sh
A note on Authentication
Media Magic utilises Auth0 for authentication, and storing personal information about users. This is for security and compliance reasons, as well as a time saver in not implementing authentication ourselves.
To create a front-end or app that integrates into our Auth0, you will need the public token, which can be provided on request.
Tokens
User Token
There are two separate tokens in use with the Media Magic API's. The first is a short-lived user token, which Auth0 returns. Which expires after three days. This token should be used in mobile apps or web apps. This token should be used for basic actions needed by user interfaces.
The user token uses the following format: Authorization: Bearer <JWT>
.
API Keys
The second is a long-lived token, which is stateful and can be invalidated with immediate effect. This token should be used for programatic use-cases. For example, interacting with the rest API to perform automated tasks. For projects and integrations, you will probably need this token. It's advised to use this token where not for use in web apps, apps, or places where a user logs in via the Auth0 login prompt.
API Keys use the following format: x-mediamagic-key: <UUID>
.
API Keys
The second is a long-lived token, which is stateful and can be invalidated with immediate effect. This token should be used for programatic use-cases. For example, interacting with the rest API to perform automated tasks. For projects and integrations, you will probably need this token. It's advised to use this token where not for use in web apps, apps, or places where a user logs in via the Auth0 login prompt.
API Keys use the following format: x-mediamagic-key: <UUID>
.
Examples
For each of these examples, we're using the user or JWT token. But you can also use the API key:
x-mediamagic-key:<API_KEY>
Rather than:
Authorization:Bearer <JWT>
Authenticate
First we grab a generated login URL from the API. Open the link returned, this will take you through the user authentication process.
Once you've authenticated, a callback url will be called with an access token. Which is then validated and swapped for a user token.
$ curl -X GET https://mediamagic.dev/api/v1/auth/login -H 'content-type: application/mediamagic.rest.v1+json'
// Example output
// {"access_token":"<token>","refresh_token":"<refresh-token>","id_token":"","token_type":"Bearer"}
Now set your auth token as an environment variable for later use.
export TOKEN=<token>
export the MMAPI. For example
export MMAPI=https://mediamagic.dev/api/v1
Create Models
source models.sh && create_models
Get Models
source models.sh && get_models
Update Models
source models.sh && update_models
Get Models by id
source models.sh && get_models_by_id
Delete Models
source models.sh && delete_models
Last updated