Page 1 of 1

Cannot retrieve data after obtaining token

Posted: Tue Mar 04, 2014 5:25 pm
by srlapides
I am able to retrieve the XML for an access token using the following VB6 code:
With http
.HTTPPostOption = "POST"
.Inputs.Add "client_credentials", "grant_type"
Call .SetRequestHeader("Authorization", ... my encoded key ...)
.URL = ..../3.1/auth/accesstoken" 'Circumvent the forum's "too spamy" msg
sHTML = .SendRequest()
End With

But when I try to provide the access token (extracted from the XML returned by the previous) in the next call using this code:
With http
.HTTPPostOption = "GET"
Call .SetRequestHeader("Authorization", ... my access token ...)
.URL = .../3.1/rest-services/published-data/publication/docdb/CO5540388/biblio" 'Circumvent the forum's "too spamy" msg

sHTML = .SendRequest()
Return
End With

What gets returned is <error><code>500</code><message>InvalidAccessToken</message></error>

Re: Cannot retrieve data after obtaining token

Posted: Wed Mar 05, 2014 11:11 am
by EPO / OPS Support
Dear user,

Could it be that you either misspelled something in access tocken or possibly did not use "Bearer"?? Please check carefully OPS documentation again.

Kind regards,

OPS support

Re: Cannot retrieve data after obtaining token

Posted: Wed Mar 05, 2014 9:04 pm
by srlapides
That fixed it. I was thrown off by the documentation for getting the AccessToken (page 41) where it said the AuthorizationHeader is Basic followed by the encoded Consumer key. That call works without the 'Basic'. Should that documentation be corrected?

Re: Cannot retrieve data after obtaining token

Posted: Thu Mar 06, 2014 1:53 pm
by EPO / OPS Support
Dear user,

You should have been looking at example on page 42 and not 41. 41 was for POST and you wanted GET
See attached:

Kind regards,

OPS support