| 44 | }; |
| 45 | |
| 46 | export const sendAuthReq = async ( |
| 47 | verifier: string, |
| 48 | authCode: string, |
| 49 | errorCallBack: any |
| 50 | ) => { |
| 51 | const appKey = PRO_CLIENT_ID ?? "cli-"; // hard-code |
| 52 | try { |
| 53 | const k = { |
| 54 | code: authCode, |
| 55 | grant_type: "authorization_code", |
| 56 | code_verifier: verifier, |
| 57 | client_id: appKey, |
| 58 | // redirect_uri: `obsidian://${COMMAND_CALLBACK_PRO}`, |
| 59 | scope: "pro.list.read", |
| 60 | }; |
| 61 | // console.debug(k); |
| 62 | const resp1 = await fetch(`${site}/api/v1/oauth2/token`, { |
| 63 | method: "POST", |
| 64 | body: new URLSearchParams(k), |
| 65 | }); |
| 66 | const resp2 = await resp1.json(); |
| 67 | return resp2; |
| 68 | } catch (e) { |
| 69 | console.error(e); |
| 70 | if (errorCallBack !== undefined) { |
| 71 | await errorCallBack(e); |
| 72 | } |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | export const sendRefreshTokenReq = async (refreshToken: string) => { |
| 77 | const appKey = PRO_CLIENT_ID ?? "cli-"; // hard-code |