Sending Authentication in Header (HTTPSecureSocket)

How do I do this in Xojo Web? (This is a valid test string provided to the public by stripe.com)

curl https://api.stripe.com/v1/charges -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: -d amount=400 -d currency=usd -d card=tok_103JBM2eZvKYlo2CGuJVAg6F -d "description=Charge for test@example.com"

I get the message “You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. ‘Authorization: Bearer YOUR_SECRET_KEY’).” doing the following. I assume the -u is CURL specific but I’m not sure how to move the sk_test_… API key to the request header.

[code] Dim req As String
Dim form As Dictionary

req = "https://api.stripe.com/v1/charges -u sk_test_BQokikJOvBiI2HlWgH4olfQ2:"

form = New Dictionary
form.Value("amount") = "400"
form.Value("currency") = "usd"
form.Value("card") = "card=tok_103JBM2eZvKYlo2CGuJVAg6F"
form.Value("description") = "Charge for test@exambple.com"

HTTPS1.SetFormData(form)
HTTPS1.Secure = True
HTTPS1.ConnectionType = SSLSocket.SSLv3
HTTPS1.Post(req)[/code]

Well until someone more knowledgeable comes along…

It seems like you need to send some security token in the request header, but I don’t see in your code where you are doing that. For instance I would have expected to see something like a call to the SetRequestHeader method perhaps.

That’s what I kinda figured. I just don’t know the syntax and what exactly to set the RequestHeader to.

Did you try

HTTPS1.SetRequestHeader("Authorization", "sk_test_BQokikJOvBiI2HlWgH4olfQ2:")

And of course, take the -u stuff out of your req string.

Thanks Tim. After taking the “:” out, it worked.