unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* http-request bearer token syntax for Twitter v2 api
@ 2022-10-12 10:30 Mortimer Cladwell
  2022-10-12 11:06 ` Olivier Dion via General Guile related discussions
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mortimer Cladwell @ 2022-10-12 10:30 UTC (permalink / raw)
  To: guile-user

Hi,
Has anyone successfully submitted a bearer token to Twitter v2 api using
http-request? What syntax did you use? Without success I have tried many
permutations/splellings/capitalizations of:

  (let* (
(uri  "https://api.twitter.com/2/tweets")
(data "{\"text\":\"Hello world!\"}")
(my-token (string-append "bearer " "abcde....myaccesstoken"))
(my-headers `((Content-type . "application/json")(Authorization .
,my-token))  )
)
      (receive (response body)
         (http-request uri #:method 'POST #:body data #:headers my-headers)
(pretty-print response) (pretty-print (utf8->string body))))

the error body:

"{\"errors\":[{\"message\":\"Requests with bodies must have content-type of
application/json.\"}],\"title\":\"Invalid Request\",\"detail\":\"One or
more parameters to your request was invalid.\",\"type\":\"
https://api.twitter.com/2/problems/invalid-request\"}"

I am not sure the "Requests with bodies must have content-type of
application/json." is the real error. I think it is "Authorization: bearer
abcde....".  Can http-request handle a bearer token?

I know my tokens are valid because I can successfully submit them using
curl.
Thanks
Mortimer


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-13 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 10:30 http-request bearer token syntax for Twitter v2 api Mortimer Cladwell
2022-10-12 11:06 ` Olivier Dion via General Guile related discussions
2022-10-12 18:33   ` Mortimer Cladwell
2022-10-13  5:53 ` James Crake-Merani
2022-10-13  8:53 ` Maxime Devos
2022-10-13 11:37 ` Ricardo Wurmus
2022-10-13 20:42   ` Mortimer Cladwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).