Skip to content

Commit

Permalink
Update grant_type=refresh_token types (#1073)
Browse files Browse the repository at this point in the history
## Description

The refresh_token response used to be more limited, but that is no
longer the case.

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
  • Loading branch information
cmatheson committed Jul 8, 2024
1 parent de35546 commit 4d03f22
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,3 @@ export interface AuthenticationResponseResponse {
impersonator?: ImpersonatorResponse;
authentication_method?: AuthenticationMethod;
}

export interface RefreshAuthenticationResponse {
accessToken: string;
refreshToken: string;
}

export interface RefreshAuthenticationResponseResponse {
access_token: string;
refresh_token: string;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
AuthenticationResponse,
AuthenticationResponseResponse,
RefreshAuthenticationResponse,
RefreshAuthenticationResponseResponse,
} from '../interfaces';
import { deserializeUser } from './user.serializer';

Expand All @@ -29,16 +27,3 @@ export const deserializeAuthenticationResponse = (
...rest,
};
};

export const deserializeRefreshAuthenticationResponse = (
refreshAuthenticationResponse: RefreshAuthenticationResponseResponse,
): RefreshAuthenticationResponse => {
const { access_token, refresh_token, ...rest } =
refreshAuthenticationResponse;

return {
accessToken: access_token,
refreshToken: refresh_token,
...rest,
};
};
1 change: 1 addition & 0 deletions src/user-management/user-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ describe('UserManagement', () => {
describe('authenticateWithRefreshToken', () => {
it('sends a refresh_token authentication request', async () => {
fetchOnce({
user: userFixture,
access_token: 'access_token',
refresh_token: 'refreshToken2',
});
Expand Down
9 changes: 3 additions & 6 deletions src/user-management/user-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import {
VerifyEmailOptions,
AuthenticateWithRefreshTokenOptions,
SerializedAuthenticateWithRefreshTokenOptions,
RefreshAuthenticationResponseResponse,
RefreshAuthenticationResponse,
MagicAuth,
MagicAuthResponse,
CreateMagicAuthOptions,
Expand All @@ -57,7 +55,6 @@ import {
serializeCreateUserOptions,
serializeSendMagicAuthCodeOptions,
serializeUpdateUserOptions,
deserializeRefreshAuthenticationResponse,
serializeAuthenticateWithRefreshTokenOptions,
serializeCreateMagicAuthOptions,
deserializeMagicAuth,
Expand Down Expand Up @@ -229,9 +226,9 @@ export class UserManagement {

async authenticateWithRefreshToken(
payload: AuthenticateWithRefreshTokenOptions,
): Promise<RefreshAuthenticationResponse> {
): Promise<AuthenticationResponse> {
const { data } = await this.workos.post<
RefreshAuthenticationResponseResponse,
AuthenticationResponseResponse,
SerializedAuthenticateWithRefreshTokenOptions
>(
'/user_management/authenticate',
Expand All @@ -241,7 +238,7 @@ export class UserManagement {
}),
);

return deserializeRefreshAuthenticationResponse(data);
return deserializeAuthenticationResponse(data);
}

async authenticateWithTotp(
Expand Down

0 comments on commit 4d03f22

Please sign in to comment.