feat(ynab): add you need a budget app integration

This commit is contained in:
Rıdvan Akca
2024-01-17 18:36:34 +03:00
parent 953c5a5b5b
commit ce6ad9e0d3
12 changed files with 256 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
import { URLSearchParams } from 'url';
export default async function generateAuthUrl($) {
const oauthRedirectUrlField = $.app.auth.fields.find(
(field) => field.key == 'oAuthRedirectUrl'
);
const redirectUri = oauthRedirectUrlField.value;
const state = Math.random().toString();
const searchParams = new URLSearchParams({
client_id: $.auth.data.clientId,
redirect_uri: redirectUri,
response_type: 'code',
state,
});
const url = `https://app.ynab.com/oauth/authorize?${searchParams.toString()}`;
await $.auth.set({
url,
originalState: state,
});
}