refactor: Use generateAuthUrl method instead of createAuthData

This commit is contained in:
Faruk AYDIN
2022-11-10 18:50:36 +01:00
parent 10e2794ff9
commit 81c41ef5ee
21 changed files with 42 additions and 50 deletions

View File

@@ -0,0 +1,18 @@
import { IField, IGlobalVariable } from '@automatisch/types';
import qs from 'qs';
export default async function generateAuthUrl($: IGlobalVariable) {
const oauthRedirectUrlField = $.app.auth.fields.find(
(field: IField) => field.key == 'oAuthRedirectUrl'
);
const redirectUri = oauthRedirectUrlField.value;
const searchParams = qs.stringify({
client_id: $.auth.data.consumerKey as string,
redirect_uri: redirectUri,
response_type: 'code',
});
await $.auth.set({
url: `${$.auth.data.oauth2Url}/authorize?${searchParams}`,
});
}