mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 01:14:36 +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.'
|
||||
)
|
||||
|
||||
return this.authManager!.logInSasjs(username, password, clientId)
|
||||
return this.authManager!.logInSasjs(username, password)
|
||||
}
|
||||
|
||||
return this.authManager!.logIn(username, password)
|
||||
|
||||
@@ -104,7 +104,7 @@ export class SASjsApiClient {
|
||||
clientId: string,
|
||||
authCode: string
|
||||
): Promise<SASjsAuthResponse> {
|
||||
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
|
||||
return getAccessTokenForSasjs(this.requestClient, authCode)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ export class SASjsApiClient {
|
||||
password: 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(
|
||||
username: string,
|
||||
password: string,
|
||||
clientId: string
|
||||
password: string
|
||||
): Promise<LoginResult> {
|
||||
const isLoggedIn = await this.sendLoginRequestSasjs(
|
||||
username,
|
||||
password,
|
||||
clientId
|
||||
)
|
||||
const isLoggedIn = await this.sendLoginRequestSasjs(username, password)
|
||||
.then((res) => {
|
||||
this.userName = username
|
||||
this.requestClient.saveLocalStorageToken(
|
||||
@@ -215,18 +210,13 @@ export class AuthManager {
|
||||
return loginResponse
|
||||
}
|
||||
|
||||
private async sendLoginRequestSasjs(
|
||||
username: string,
|
||||
password: string,
|
||||
clientId: string
|
||||
) {
|
||||
private async sendLoginRequestSasjs(username: string, password: string) {
|
||||
const authCode = await getAuthCodeForSasjs(
|
||||
this.requestClient,
|
||||
username,
|
||||
password,
|
||||
clientId
|
||||
password
|
||||
)
|
||||
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
|
||||
return getAccessTokenForSasjs(this.requestClient, authCode)
|
||||
}
|
||||
/**
|
||||
* Checks whether a session is active, or login is required.
|
||||
|
||||
@@ -9,12 +9,10 @@ import { RequestClient } from '../request/RequestClient'
|
||||
*/
|
||||
export async function getAccessTokenForSasjs(
|
||||
requestClient: RequestClient,
|
||||
clientId: string,
|
||||
authCode: string
|
||||
) {
|
||||
const url = '/SASjsApi/auth/token'
|
||||
const data = {
|
||||
clientId,
|
||||
code: authCode
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,10 @@ import { RequestClient } from '../request/RequestClient'
|
||||
export const getAuthCodeForSasjs = async (
|
||||
requestClient: RequestClient,
|
||||
username: string,
|
||||
password: string,
|
||||
clientId: string
|
||||
password: string
|
||||
) => {
|
||||
const url = '/SASjsApi/auth/authorize'
|
||||
const data = { username, password, clientId }
|
||||
const data = { username, password }
|
||||
|
||||
const { code: authCode } = await requestClient
|
||||
.post<{ code: string }>(url, data, undefined)
|
||||
|
||||
@@ -22,15 +22,11 @@ describe('getAccessTokenForSasjs', () => {
|
||||
Promise.resolve({ result: mockSasjsAuthResponse, etag: '' })
|
||||
)
|
||||
|
||||
await getAccessTokenForSasjs(
|
||||
requestClient,
|
||||
authConfig.client,
|
||||
authConfig.refresh_token
|
||||
)
|
||||
await getAccessTokenForSasjs(requestClient, authConfig.refresh_token)
|
||||
|
||||
expect(requestClient.post).toHaveBeenCalledWith(
|
||||
'/SASjsApi/auth/token',
|
||||
{ clientId: authConfig.client, code: authConfig.refresh_token },
|
||||
{ code: authConfig.refresh_token },
|
||||
undefined
|
||||
)
|
||||
})
|
||||
@@ -51,7 +47,6 @@ describe('getAccessTokenForSasjs', () => {
|
||||
|
||||
const error = await getAccessTokenForSasjs(
|
||||
requestClient,
|
||||
authConfig.client,
|
||||
authConfig.refresh_token
|
||||
).catch((e) => e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user