microscopic-answer-24504
07/04/2023, 5:49 AMnumerous-dawn-55367
07/10/2023, 2:13 PMnumerous-dawn-55367
07/10/2023, 3:26 PMdamp-television-87203
07/11/2023, 1:48 PMnumerous-dawn-55367
07/11/2023, 1:50 PMdamp-television-87203
07/11/2023, 1:56 PMdamp-television-87203
07/11/2023, 1:58 PMthankful-lion-29218
07/13/2023, 6:20 AMdefp check_session(%Plug.Conn{} = conn) do
connection = Ory.Connection.new([{"token", "Bearer MY_TOKEN"}])
[cookies] = Plug.Conn.get_req_header(conn, "cookie")
case Ory.Api.Frontend.to_session(connection, [{"Cookie", cookies}]) do
{:ok, %Ory.Model.Session{} = session} ->
{:ok, session}
{:ok, %Ory.Model.ErrorGeneric{} = err} ->
{:error, err}
{:error, %Tesla.Env{} = err} ->
{:error, err}
{:error, err} ->
{:error, err}
end
end
thankful-lion-29218
07/13/2023, 6:25 AM** (FunctionClauseError) no function clause matching in Tesla.put_header/3
when I call it like you do in your example:
case Ory.Api.Frontend.to_session(connection, Cookie: cookies) do
numerous-dawn-55367
07/13/2023, 6:47 AMkey=value;
manor https://github.com/tobbbles/examples/blob/a18a92fda34d66c121042a2f9a910b1aa373c04e/elixir-ory-network/lib/example_web/helpers.ex#L6thankful-lion-29218
07/13/2023, 6:48 AMthankful-lion-29218
07/13/2023, 6:49 AMthankful-lion-29218
07/13/2023, 10:26 AMnumerous-dawn-55367
07/13/2023, 11:48 AMthankful-lion-29218
07/13/2023, 12:16 PMnumerous-dawn-55367
07/13/2023, 12:21 PMconfig :tesla, Tesla.Middleware.Logger, debug: true
in the config?thankful-lion-29218
07/13/2023, 12:25 PM** (FunctionClauseError) no function clause matching in anonymous fn/1 in Tesla.Adapter.Httpc.request/2
(tesla 1.7.0) lib/tesla/adapter/httpc.ex:55: anonymous fn("authorization") in Tesla.Adapter.Httpc.request/2
From this call:
Ory.Api.Relationship.list_relationship_namespaces(
Ory.Connection.new("Bearer MY_TOKEN")
)
numerous-dawn-55367
07/13/2023, 12:33 PMOry.Connection
model and try to make a Tesla client yourself with the correct BearerAuth middleware attached and pass that to your admin operation functions;
You'll see an example client implementation here;
https://hexdocs.pm/tesla/Tesla.Middleware.BearerAuth.html
And how you can plug the base url stuff etc at https://hexdocs.pm/tesla/readme.html
If that works well, then I think this is the recommended way of creating authenticated clients for admin operations with the SDK, until overhauling the upstream generated elixir clientnumerous-dawn-55367
07/13/2023, 1:18 PMclient = Tesla.client([
{Tesla.Middleware.BearerAuth, token: "MY_TOKEN"},
Tesla.Middleware.EncodeJson,
{Tesla.Middleware.BaseUrl, "<https://my-project.projects.oryapis.com>"}
])
supplied as a client it works happilythankful-lion-29218
07/13/2023, 3:38 PMnumerous-dawn-55367
07/14/2023, 7:46 AM