ancient-barista-28319
09/27/2022, 3:42 PMlocalhost:3004
is giving me
error: {
code: 401,
status: 'Unauthorized',
request: '98aaa3f0-096e-9cbd-91e5-ee148beefcd3',
message: 'Access credentials are invalid'
}
when I run below code, where import.meta.env.ORY_PAT
is my personal access token:
import keto from "@ory/keto-client";
...
try {
const config = new keto.Configuration({
basePath: "<http://localhost:3004>",
accessToken: import.meta.env.ORY_PAT,
});
const readClient = new keto.ReadApi(config);
const response = await readClient.getCheck(
"venues",
"se-hq-it",
"assortment:read",
session.identity.id
);
} catch (error: any) {
console.error(error.response);
}
...
Anyone have a clue what I'm missing here?ancient-barista-28319
09/28/2022, 8:31 AMfetch
ancient-barista-28319
09/28/2022, 9:45 AMancient-barista-28319
09/28/2022, 9:46 AMimport.meta.env.ORY_API_URL
and Ory access token in `import.meta.env.ORY_PAT`:
const url = `${import.meta.env.ORY_API_URL}/relation-tuples/check`;
const body = {
namespace: "venues",
object: "se-hq-it",
relation: "assortment:read",
subject: session.identity.id,
};
const headers = new Headers({
Authorization: `Bearer ${import.meta.env.ORY_PAT}`,
"Content-Type": "application/json"
});
const response = await fetch(url, {
body: JSON.stringify(body),
headers,
method: "POST",
});
the request fails with:
{
status: 502,
statusText: 'Bad Gateway',
}
but the same request via Postman and cUrl works perfectly fine. Any input here is very appreciated.ancient-barista-28319
09/28/2022, 9:47 AMnode
, for the recordancient-barista-28319
09/28/2022, 9:48 AMcurl --location --request POST 'https://{project}.<http://projects.oryapis.com/relation-tuples/check|projects.oryapis.com/relation-tuples/check>' \
--header 'Authorization: Bearer ORY_PAT' \
--header 'Content-Type: application/json' \
--data-raw '{
"namespace": "venues",
"object": "se-hq-it",
"relation": "assortment:read",
"subject_id": "a79e6e35-029f-4c50-b64f-305308c7eb9d"
}'
steep-lamp-91158
ory proxy
or ory tunnel
to forward the requests? that should not really be needed as keto is not cookie/browser basedancient-barista-28319
09/28/2022, 10:07 AMsteep-lamp-91158
Bad Gateway
, but one difference I see is that in the node fetch you have the wrong key, subject
while in curl you use the right one subject_id
ancient-barista-28319
09/28/2022, 10:08 AMancient-barista-28319
09/28/2022, 10:09 AMancient-barista-28319
09/28/2022, 10:09 AMsteep-lamp-91158
ancient-barista-28319
09/28/2022, 10:10 AMsteep-lamp-91158
ancient-barista-28319
09/28/2022, 10:11 AMsteep-lamp-91158
ancient-barista-28319
09/28/2022, 10:13 AM"@ory/keto-client": "^0.10.0-alpha.0",
steep-lamp-91158
ancient-barista-28319
09/28/2022, 10:14 AMancient-barista-28319
09/28/2022, 10:15 AMsteep-lamp-91158
ancient-barista-28319
09/28/2022, 10:16 AMancient-barista-28319
09/28/2022, 10:17 AMancient-barista-28319
09/28/2022, 10:17 AMsteep-lamp-91158
narrow-van-43826
09/28/2022, 12:36 PM