5

I'm trying to connect to the Adobe Analytics found here

I've managed to generate an auth token using the below request:

curl -i -v "https://api.omniture.com/token" -u 'my-user' -d "grant_type=client_credentials"

I then copy the whole object thats returned which looks something like this:

{
  "access_token": "some-really-long-access-token",
  "expires_in": 3600,
  "token_type": "bearer",
  "scope": "livestream",
  "success": true
}

and paste it into the following cURL:

curl --location --compressed --header “Authorization: Bearer [{"access_token":"some-really-long-access-token","expires_in":3600,"token_type":"bearer","scope":"livestream","success":true}]” [https://livestream.adobe.net/api/1/stream/myendpoint]

The error i'm getting is:

Couldn't resolve host 'Bearer'

I'm fairly new to cURL so not sure if there is an obvious error here? Will most likely be down to the way i'm sending the data over...

EDIT

After the answer written below this is the error message i'm getting:

curl: (6) Couldn't resolve host 'Bearer'
curl: (6) Couldn't resolve host 'some-really-long-auth-key
invalid authorization header
miken32
  • 42,008
  • 16
  • 111
  • 154
red house 87
  • 1,837
  • 9
  • 50
  • 99
  • Does this answer your question? [How to check uploaded file type in PHP](https://stackoverflow.com/questions/6755192/how-to-check-uploaded-file-type-in-php) – miken32 Dec 31 '19 at 17:06
  • Had a similar problem in windows cmd, but WSL2 ran it with no issues. – patrick Jun 07 '23 at 13:38

1 Answers1

10

Okay, the part you need to pass in the header is the "some-really-long-access-token"

Example:

curl --compressed --header "Authorization: Bearer some-really-long-access-token" "https://livestream.adobe.net/api/1/stream/myendpoint"

So just pay attention to the encoding on the ".

  • is not the same as "
  • When copying / pasting from HTML, Rich text, or something other than a code block, it's best to check this

Edit:

Your question is tagged php, but your examples are using the command line, therefore, ensure your command is formatted using the following points:

First and foremost:

enter image description here

Other general things to check:

  • A header is passed like this: -H "Header-name: Header-Value"

    • Therefore, if my access token was 29035-97v657zyr8qk966y143k2v0p365460xbd1pvk9p6 Then my header arguments would be this:
      • -H "Authorization: Bearer 29035-97v657zyr8qk966y143k2v0p365460xbd1pvk9p6"
  • You can explicitly specify the url to cURL using --url. I don't usually do this because it shouldn't be necessary if everything is correct, but it may help refine the error message.

    • So my URL arguments would be this:
      • --url "https://livestream.adobe.net/api/1/stream/myendpoint"
  • Be sure as described above NOT to use LEFT AND RIGHT DOUBLE QUOTATION MARK and , but the standard " found on the computer keyboard. The standard " is what the shell uses to contain arguments

hmedia1
  • 5,552
  • 2
  • 22
  • 27
  • I tried what you said but still getting an error. See my edited question above for the error im getting – red house 87 May 19 '17 at 11:11
  • Can you post in your edit the *exact* command (you can change your endpoint to just /endpoint and your access token to just access-token) – hmedia1 May 19 '17 at 11:36
  • @BenLiger I've modified my answer to be more helpful - But I will need to modify it again to be more generic and benefit the rest of the community once your problem is resolved, so please post back here your results asap – hmedia1 May 19 '17 at 11:53
  • hey thanks for the reply but now i'm getting this error: 'token' is not recognized as an internal or external command, – red house 87 May 19 '17 at 12:47
  • @BenLiger You clearly have syntax errors and shell quoting issues. Please see my edited example, particularly the section "First and foremost" to make absolutely sure you fix that up first. What happens when you copy and paste my very first dummy example (on the third line of my answer), into the shell. It should say "401 unauthorized" and eventually say "internal error". Please confirm this. – hmedia1 May 20 '17 at 00:26