Archived Forum Post

Index of archived forum posts

Question:

Foxro Simple Get using Access Token

Sep 19 '17 at 10:16

Hello, I have been given an API specification which includes an access token that maps to my user and password on the host system. I'm trying to do a simple GET. When I post the example URL below in Google Chrome it produces the correct JSON response.

http://my_token@hostdomain.net/employees/441/address.json

So I'm trying to duplicate using Chilkat Active X:

loHttp = CreateObject('Chilkat_9_5_0.Http')
lcResp = loHttp.quickgetstr("http://my_token@hostdomain.net/employees/441/address.json")

And the response is producing error 401 Unauthorized. Any clues on sending a GET with an access code?

Thanks.


Answer

I suspect Chrome is finding a Cookie and sending it with.

Are you able to use Fiddler to see what is being sent in the headers from Chrome? http://www.telerik.com/fiddler


Answer

Cookies are often set from within Javascript. When a browser loads HTML, it loads the HTML into a Document Object Model (DOM), and then it may run Javascript (contained withing the HTML) against the DOM. That Javascript can often create cookies, and those cookies can get sent with subsequent requests.

When using an API such s Chilkat, there is no Javascript engine. You're just receiving the HTML of the web page. If the cookies came into being via Javascript then those cookies won't exist with Chilkat. It would require far more infrastructure within Chilkat, such as building out a DOM and an embedded Javascript engine to simulate a browser.