Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create HTTP Request object
Message
From
22/12/2016 08:19:47
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01645753
Message ID:
01645880
Views:
50
>>>
>>>I am getting Authorization Denied message. So something is wrong but not with your code. Thank you.
>>
>>Were you given credentials to access the service? A username and password? Normally, you have 3 choices to send them to the WebService
>>
>>1. As an header (through m.HttpRequest.SetRequestHeader);
>>
>>2. As a parameter (since you're using GET, that would be in the querystring, that is, value pairs after a ? in the URL);
>>
>>3. Or, more simply, as username and password parameters of the m.HttpRequest.Open method: m.HttpRequest.Open("GET", m.HttpResponseEndPoint, .F., m.UsertName, m.Password) - of course, m.UserName and m.Password being previously set.
>
>The way this Web API works is that, first I have to call a service and pass a user name and password. And I get a token in return (JSON) authorizing further calls to the Web API. I did the first call and verified that the returned token is valid. I can see it in the debugger.
>Then, by design of this Web API, when I need to call another server (like get records from a table), I have to pass - in the Header - this token that I got with the first call. Here is the problem. When I add the value of this token (exact syntax specified by the developer is ("Authorization", "bearer " + _token) I get back the message that "Authorization has been denied for this request."
>
>Note that by design of this Web API, I don't need to pass user name and password on any further calls. And I see this code works in the sample C# example the developer of Web API provided.
>
>I think the problem is in the Header. That is I need to find out if the value I add to the Header goes to the "right" header.
>
>I am guessing that maybe when I add [ ("Authorization", "bearer " + _token) ] to the header, it does not set to the right header property. For example, if I use the wwHTTP class suggested by Thierry, and use the method AddHeader(), the value actually is assigned to the property named "cExtraheaders". Which does not work.

Ok, I see two potential issues here: a) extraction of the correct value of the token from the JSON reply; b) the header may require some kind of encoding (base64, for instance). Can you paste here the C# code, with any sensitive information properly redacted?
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform