1Password / onepassword-sdk-js

The official JavaScript SDK for 1Password
https://developer.1password.com/docs/sdks/
MIT License
48 stars 2 forks source link

authentication error: http error: error issuing the request with reqwest: error sending request: JsValue(TypeError: Only absolute URLs are supported #105

Open mesaque opened 2 weeks ago

mesaque commented 2 weeks ago

Scenario & Reproduction Steps

node v22.5.0

authentication error: http error: error issuing the request with reqwest: error sending request: JsValue(TypeError: Only absolute URLs are supported TypeError: Only absolute URLs are supported at getNodeRequestOptions (/Users/xxx/Documents/www/xxx/node_modules/node-fetch/lib/index.js:1327:9) at /Users/xxx/Documents/www/xxx/node_modules/node-fetch/lib/index.js:1450:19 at new Promise () at fetch (/Users/xxx/Documents/www/xxx/node_modules/node-fetch/lib/index.js:1447:9) at module.exports.__wbg_fetch_bc7c8e27076a5c84 (/Users/xxx/Documents/www/xxx/node_modules/@1password/sdk-core/nodejs/core.js:312:17) at op_js_core.wasm.reqwest::wasm::client::js_fetch::ha27955dbb1f30d16 (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[3158]:0x2e2f95) at op_js_core.wasm.::request::{{closure}}::h3a181331326cc5ba (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[107]:0x84076) at op_js_core.wasm.::request::{{closure}}::hff893f425ad048ce (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[686]:0x1d2edd) at op_js_core.wasm.op_service_account_authentication::lookup_auth::{{closure}}::hefde251e07cc903f (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[221]:0x1029db) at op_js_core.wasm.::new_unverified_session::{{closure}}::he3cc43e42663c1ac (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[78]:0x3d794) at op_js_core.wasm.<core::pin::Pin

as core::future::future::Future>::poll::h8866a0ab15d095a0 (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[89]:0x5e474) at op_js_core.wasm.wasm_bindgen_futures::future_to_promise::{{closure}}::{{closure}}::h8eb95870477ddaf6 (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[484]:0x190a43) at op_js_core.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h40a7ee1c15b8d20a (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[1431]:0x2572c1) at op_js_core.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h992c8f981e42a5a1 (wasm://wasm/op_js_core.wasm-014254e6:wasm-function[4791]:0x30ca09) at __wbg_adapter_26 (/Users/xxx/Documents/www/xxx/node_modules/@1password/sdk-core/nodejs/core.js:219:10) at real (/Users/xxx/Documents/www/xxx/node_modules/@1password/sdk-core/nodejs/core.js:204:20))

My Code:

let client = await sdk.createClient({ auth: process.env.OP_SERVICE_ACCOUNT_TOKEN, // Set the following to your own integration name and version. integrationName: "XXX", integrationVersion: "v1.0.0", });

Actual Behavior

i am running the current example on github page

Expected Behavior

conect

SDK version

@1password/sdk@0.1.3

Additional information

No response

hculea commented 1 week ago

Hey @mesaque , thank you for reporting!

That is unexpected - Is your service account token a valid one? You can check this with the 1Password CLI - exporting the token to the OP_SERVICE_ACCOUNT_TOKEN environment variable and running an op whoami command, after installing the CLI.

Additionally, you can check the formatting of your service account to see the actual URL that it makes requests for:

echo $OP_SERVICE_ACCOUNT_TOKEN | base64 -d

You should get back a JSON with a signInAddress field - is the value of that field expected? Is it prefixed with https:// or suffixed by anything after .com/.eu/.ca?

Let us know, happy to debug this further, thank you.