mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 12:30:06 +00:00
fix: deprecating sasjs client id
This commit is contained in:
@@ -598,7 +598,7 @@ export default class SASjs {
|
|||||||
'A username, password and clientId are required when using the default login mechanism with server type SASJS.'
|
'A username, password and clientId are required when using the default login mechanism with server type SASJS.'
|
||||||
)
|
)
|
||||||
|
|
||||||
return this.authManager!.logInSasjs(username, password, clientId)
|
return this.authManager!.logInSasjs(username, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authManager!.logIn(username, password)
|
return this.authManager!.logIn(username, password)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export class SASjsApiClient {
|
|||||||
clientId: string,
|
clientId: string,
|
||||||
authCode: string
|
authCode: string
|
||||||
): Promise<SASjsAuthResponse> {
|
): Promise<SASjsAuthResponse> {
|
||||||
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
|
return getAccessTokenForSasjs(this.requestClient, authCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +126,7 @@ export class SASjsApiClient {
|
|||||||
password: string,
|
password: string,
|
||||||
clientId: string
|
clientId: string
|
||||||
) {
|
) {
|
||||||
return getAuthCodeForSasjs(this.requestClient, username, password, clientId)
|
return getAuthCodeForSasjs(this.requestClient, username, password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,14 +92,9 @@ export class AuthManager {
|
|||||||
*/
|
*/
|
||||||
public async logInSasjs(
|
public async logInSasjs(
|
||||||
username: string,
|
username: string,
|
||||||
password: string,
|
password: string
|
||||||
clientId: string
|
|
||||||
): Promise<LoginResult> {
|
): Promise<LoginResult> {
|
||||||
const isLoggedIn = await this.sendLoginRequestSasjs(
|
const isLoggedIn = await this.sendLoginRequestSasjs(username, password)
|
||||||
username,
|
|
||||||
password,
|
|
||||||
clientId
|
|
||||||
)
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.userName = username
|
this.userName = username
|
||||||
this.requestClient.saveLocalStorageToken(
|
this.requestClient.saveLocalStorageToken(
|
||||||
@@ -215,18 +210,13 @@ export class AuthManager {
|
|||||||
return loginResponse
|
return loginResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sendLoginRequestSasjs(
|
private async sendLoginRequestSasjs(username: string, password: string) {
|
||||||
username: string,
|
|
||||||
password: string,
|
|
||||||
clientId: string
|
|
||||||
) {
|
|
||||||
const authCode = await getAuthCodeForSasjs(
|
const authCode = await getAuthCodeForSasjs(
|
||||||
this.requestClient,
|
this.requestClient,
|
||||||
username,
|
username,
|
||||||
password,
|
password
|
||||||
clientId
|
|
||||||
)
|
)
|
||||||
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
|
return getAccessTokenForSasjs(this.requestClient, authCode)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Checks whether a session is active, or login is required.
|
* Checks whether a session is active, or login is required.
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ import { RequestClient } from '../request/RequestClient'
|
|||||||
*/
|
*/
|
||||||
export async function getAccessTokenForSasjs(
|
export async function getAccessTokenForSasjs(
|
||||||
requestClient: RequestClient,
|
requestClient: RequestClient,
|
||||||
clientId: string,
|
|
||||||
authCode: string
|
authCode: string
|
||||||
) {
|
) {
|
||||||
const url = '/SASjsApi/auth/token'
|
const url = '/SASjsApi/auth/token'
|
||||||
const data = {
|
const data = {
|
||||||
clientId,
|
|
||||||
code: authCode
|
code: authCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import { RequestClient } from '../request/RequestClient'
|
|||||||
export const getAuthCodeForSasjs = async (
|
export const getAuthCodeForSasjs = async (
|
||||||
requestClient: RequestClient,
|
requestClient: RequestClient,
|
||||||
username: string,
|
username: string,
|
||||||
password: string,
|
password: string
|
||||||
clientId: string
|
|
||||||
) => {
|
) => {
|
||||||
const url = '/SASjsApi/auth/authorize'
|
const url = '/SASjsApi/auth/authorize'
|
||||||
const data = { username, password, clientId }
|
const data = { username, password }
|
||||||
|
|
||||||
const { code: authCode } = await requestClient
|
const { code: authCode } = await requestClient
|
||||||
.post<{ code: string }>(url, data, undefined)
|
.post<{ code: string }>(url, data, undefined)
|
||||||
|
|||||||
@@ -22,15 +22,11 @@ describe('getAccessTokenForSasjs', () => {
|
|||||||
Promise.resolve({ result: mockSasjsAuthResponse, etag: '' })
|
Promise.resolve({ result: mockSasjsAuthResponse, etag: '' })
|
||||||
)
|
)
|
||||||
|
|
||||||
await getAccessTokenForSasjs(
|
await getAccessTokenForSasjs(requestClient, authConfig.refresh_token)
|
||||||
requestClient,
|
|
||||||
authConfig.client,
|
|
||||||
authConfig.refresh_token
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(requestClient.post).toHaveBeenCalledWith(
|
expect(requestClient.post).toHaveBeenCalledWith(
|
||||||
'/SASjsApi/auth/token',
|
'/SASjsApi/auth/token',
|
||||||
{ clientId: authConfig.client, code: authConfig.refresh_token },
|
{ code: authConfig.refresh_token },
|
||||||
undefined
|
undefined
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -51,7 +47,6 @@ describe('getAccessTokenForSasjs', () => {
|
|||||||
|
|
||||||
const error = await getAccessTokenForSasjs(
|
const error = await getAccessTokenForSasjs(
|
||||||
requestClient,
|
requestClient,
|
||||||
authConfig.client,
|
|
||||||
authConfig.refresh_token
|
authConfig.refresh_token
|
||||||
).catch((e) => e)
|
).catch((e) => e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user