Wowza Community

Curl command to create mediacache with google storage source (credentials issue)

Hi I am trying to setup a mediacache with google cloud storage as a source using the rest API however I I am getting a jackson parse error due to the credentials not being what is expected. Can you please correct this curl command so that I can add the google credentials or advise how to encrypt.

  curl -X POST \

-H 'Accept:application/json; charset=utf-8' \

-H 'Content-type:application/json; charset=utf-8' \

http://127.0.0.1:8087/v3/servers/_defaultServer_/mediacache/sources/media-store-prod-input-1 \

-d '

{

    "type": "GoogleCloudStorage",

    "basePath": "https://storage.googleapis.com/",

    "prefix": "http/",

    "minTimeToLive": 14400000,

    "maxTimeToLive": 28800000,

    "isAmazonS3": false,

    "s3BucketNameInDomain": false,

    "awsAccessKeyId": "",

    "awsSecretAccessKey": "",

    "isPassThru": false,

    "baseClass": "com.wowza.wms.mediacache.impl.MediaCacheItemHTTPImpl",

    "httpReaderFactoryClass": "com.wowza.wms.mediacache.impl.MediaCacheItemHTTPGoogleStorageFactory",

    "azureAccountName": "",

    "azureContainerName": "",

    "azureAccountKey": "",

    "googleServiceID": "some-cloud-storage-prod@myproject.iam.gserviceaccount.com",

    "googleServiceKey": {

        "type": "service_account",

        "project_id": "some-project",

        "private_key_id": "XXXXXXXXXXX",

        "private_key": "-----BEGIN PRIVATE KEY-----\XXXXXXXXXXXXXXX\XXXXXXXXX+XXXXXXXXXX==\n-----END PRIVATE KEY-----\n",

        "client_email": "some-cloud-storage-prod@myproject.iam.gserviceaccount.com",

        "client_id": "115155345353555353",

        "auth_uri": "https://accounts.google.xcom/o/oauth2/auth",

        "token_uri": "https://oauth2.googleapis.com/token",

        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",

        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/someones-cloud-storage-prod%40myproject.iam.gserviceaccount.com"

      },

    "googleServicePrivateKeyFile": "",

    "googleServicePrivateKeyPassword": "",

    "googleEncMethod": "JSON"

  }' | jq

I get the following response:

  "message": "com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token\n at [Source: (ByteArrayInputStream); line: 19, column: 25] (through reference chain: com.wowza.wms.rest.server.mediacache.MediaCacheSourceConfig3[\"googleServiceKey\"])",

based the command by querying an instance I setup earlier and manually configured, but the key is just an encrypted string in that instance.

What is the correct way of doing this? I will inject the service account credentials in via an environment variable / secret in real life.

Checking with an REST API engineer for you…

You essentially have to get a hash of that code that you included @Justin Cooke. If you are using the JSON authenticationType, you will need to change the \n characters in the JSON file you downloaded to a newline, and then Base64 to UTF-8 charset the private_key value from the JSON file. You can use any online tool to do this (such as base64encode.org). Use the output in the secretAccessKey parameter.

Each GCE account would have its own key, that they need to convert to a hash.

Those keys are found in a JSON file that you got from Google site.

It sounds like you have the json file already, You just need direction on how to obtain the hash.

Please submit a ticket if you have any issues. Thanks.