Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/oauth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"dotenv": "^16.4.5",
"express": "^4.19.2",
"handlebars": "^4.7.8",
"jsonwebtoken": "^9.0.2"
"jsonwebtoken": "^9.0.2",
"qs": "^6.13.0"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
"@types/qs": "^6.9.17",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
Expand Down
5 changes: 4 additions & 1 deletion core/oauth/src/connections/jira/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export const init = async ({ body }: DataObject): Promise<OAuthResponse> => {
const response = await axios({
url: 'https://auth.atlassian.com/oauth/token',
method: 'POST',
params: {
headers: {
'Content-Type': 'application/json',
},
data: {
grant_type: 'authorization_code',
code,
client_id,
Expand Down
5 changes: 4 additions & 1 deletion core/oauth/src/connections/jira/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const refresh = async ({ body }: DataObject): Promise<OAuthResponse> => {
const response = await axios({
url: 'https://auth.atlassian.com/oauth/token',
method: 'POST',
params: {
headers: {
'Content-Type': 'application/json',
},
data: {
grant_type: 'refresh_token',
refresh_token,
client_id,
Expand Down
20 changes: 16 additions & 4 deletions core/oauth/src/connections/zoho/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import qs from 'qs';
import { DataObject, OAuthResponse } from '../../lib/types';

export const init = async ({ body }: DataObject): Promise<OAuthResponse> => {
Expand All @@ -14,11 +15,22 @@ export const init = async ({ body }: DataObject): Promise<OAuthResponse> => {
additionalData['accounts-server'],
);

let url = `${ZOHO_ACCOUNTS_DOMAIN}/oauth/v2/token?grant_type=authorization_code`;
url += `&client_id=${clientId}&client_secret=${clientSecret}`;
url += `&code=${code}&redirect_uri=${redirectUri}`;
const requestBody = {
grant_type: 'authorization_code',
client_id: clientId,
client_secret: clientSecret,
code,
redirect_uri: redirectUri,
};

const response = await axios.post(url);
const response = await axios({
url: `${ZOHO_ACCOUNTS_DOMAIN}/oauth/v2/token`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify(requestBody),
});

const {
data: {
Expand Down
18 changes: 15 additions & 3 deletions core/oauth/src/connections/zoho/refresh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import qs from 'qs';
import { DataObject, OAuthResponse } from '../../lib/types';

export const refresh = async ({ body }: DataObject): Promise<OAuthResponse> => {
Expand All @@ -13,10 +14,21 @@ export const refresh = async ({ body }: DataObject): Promise<OAuthResponse> => {
let refreshToken = refresh_token;
const ZOHO_ACCOUNTS_DOMAIN = meta.ZOHO_ACCOUNTS_DOMAIN;

let url = `${ZOHO_ACCOUNTS_DOMAIN}/oauth/v2/token?grant_type=refresh_token`;
url += `&client_id=${client_id}&client_secret=${client_secret}&refresh_token=${refresh_token}`;
const requestBody = {
grant_type: 'refresh_token',
client_id,
client_secret,
refresh_token,
};

const response = await axios.post(url);
const response = await axios({
url: `${ZOHO_ACCOUNTS_DOMAIN}/oauth/v2/token`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify(requestBody),
});

const {
data: {
Expand Down