Closed oDinZu closed 1 year ago
This populated the JWT: login.response :logger, nil, { bodies: true }
Edit: I am still unsure how to pass the debug log data.
INFO -- response: {"jwt":"exampleODYzNjQ1LCJleHAiOjE2NzI0NexamplepwTfbwEO8bZP4GNyPw","user":...
As an example, puts api_login.response("jwt")
I got the authorization token working, but things are very different when I need to authorize a user
, then get that fresh user token
to then generate json data
from an API.
Hallelujah! :tada:
This code does exactly what I need it to do!
There is the first time this has been shared on the WWW for Ruby / Strapi integration. I hope it serves you well :heart: !
connection = Faraday.new(auth_login) do |b|
b.request :json # This will set the "Content-Type" header to application/json and call .to_json on the body
b.response(:json, content_type: /\bjson$/)
b.adapter :httpx # default is Net:HTTP see README.md
end
response = connection.post(auth_login, { "identifier": strapi_bot_user_email, "password": strapi_bot_user_pass })
strapi_token = response.body["jwt"]
Faraday Version: 2.7.1
Hi :wave: I am having trouble getting the JWT from my POST.
I receive a status code of 200 and the logger shows everything but the body.
The code:
The STDOUT:
I have tested many different variations.
I thought it would work with this:
puts api_login.body
; theputs api_login.headers
works.