feat: multi client id use added
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import apiClient from '@/lib/apiClient';
|
||||
|
||||
export interface GenerateTokenWithPassword {
|
||||
export interface GenerateToken {
|
||||
client_id: string;
|
||||
}
|
||||
|
||||
export interface GenerateTokenWithPassword extends GenerateToken {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
@@ -18,8 +22,11 @@ export const generateTokenWithPassword = (
|
||||
) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'password');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
body.set('client_id', request.client_id);
|
||||
body.set(
|
||||
'scope',
|
||||
import.meta.env.VITE_IDENTITY_SCOPE + ' ' + request.client_id,
|
||||
);
|
||||
body.set('username', request.username);
|
||||
body.set('password', request.password);
|
||||
|
||||
@@ -34,7 +41,7 @@ export const generateTokenWithPassword = (
|
||||
);
|
||||
};
|
||||
|
||||
export interface GenerateTokenWithOTP {
|
||||
export interface GenerateTokenWithOTP extends GenerateToken {
|
||||
email?: string;
|
||||
phonenumber?: string;
|
||||
otp: string;
|
||||
@@ -43,8 +50,11 @@ export interface GenerateTokenWithOTP {
|
||||
export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'otp');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
body.set('client_id', request.client_id);
|
||||
body.set(
|
||||
'scope',
|
||||
import.meta.env.VITE_IDENTITY_SCOPE + ' ' + request.client_id,
|
||||
);
|
||||
if (request.email) body.set('email', request.email);
|
||||
if (request.phonenumber) body.set('phonenumber', request.phonenumber);
|
||||
body.set('otp_code', request.otp);
|
||||
@@ -60,15 +70,18 @@ export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => {
|
||||
);
|
||||
};
|
||||
|
||||
export interface GenerateTokenWithGoogle {
|
||||
export interface GenerateTokenWithGoogle extends GenerateToken {
|
||||
idToken: string;
|
||||
}
|
||||
|
||||
export const generateTokenWithGoogle = (request: GenerateTokenWithGoogle) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'google');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
body.set('client_id', request.client_id);
|
||||
body.set(
|
||||
'scope',
|
||||
import.meta.env.VITE_IDENTITY_SCOPE + ' ' + request.client_id,
|
||||
);
|
||||
body.set('idtoken', request.idToken);
|
||||
|
||||
return apiClient.post<GenerateTokenResponse>(
|
||||
|
||||
Reference in New Issue
Block a user