Skip to content

Commit f91c2b9

Browse files
committed
fix!: remove oauth2 scope
1 parent 7fb18a8 commit f91c2b9

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

src/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ describe('OAuthClientCredentialsClient', () => {
5555
expect(fakeFormData.append).toHaveBeenCalledWith('grant_type', 'client_credentials');
5656
expect(fakeFormData.append).toHaveBeenCalledWith('client_id', clientId);
5757
expect(fakeFormData.append).toHaveBeenCalledWith('client_secret', clientSecret);
58-
expect(fakeFormData.append).toHaveBeenCalledWith('scope', 'restricted');
5958
expect((sut as any)._fetch).toHaveBeenCalledWith(
6059
jasmine.anything(),
6160
jasmine.objectContaining({

src/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class OAuthClientCredentialsClient implements ApiClient {
3636
body.append('grant_type', 'client_credentials');
3737
body.append('client_id', this._clientId);
3838
body.append('client_secret', this._clientSecret);
39-
body.append('scope', 'restricted');
4039
const request = {
4140
method,
4241
body,

src/common/data/table-data/table-data-client/table-data-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class TableDataClient {
1313
async postGetData<T, U = Record<string, unknown> | undefined>(
1414
request: TableDataRequest,
1515
formParts: Record<string, string> = {}
16-
): Promise<BugSplatResponse<TableDataResponse<T, U>>> {
16+
): Promise<BugSplatResponse<TableDataResponse<T, U> | ErrorResponse>> {
1717
const factory = () => this._apiClient.createFormData();
1818
const formData = new TableDataFormDataBuilder(factory, formParts)
1919
.withDatabase(request.database)
@@ -95,3 +95,5 @@ export class TableDataClient {
9595
export type RawResponse<T> = Array<{
9696
[Property in keyof T as Capitalize<string & Property>]: T[Property];
9797
}>;
98+
99+
export type ErrorResponse = { message: string };

src/crashes/crashes-api-client/crashes-api-client.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@common';
88
import { CrashesApiRow, CrashesPageData } from '@crashes';
99
import { CrashesApiResponseRow } from '../crashes-api-row/crashes-api-row';
10+
import { ErrorResponse } from 'src/common/data/table-data/table-data-client/table-data-client';
1011

1112
export class CrashesApiClient {
1213
private _tableDataClient: TableDataClient;
@@ -35,8 +36,22 @@ export class CrashesApiClient {
3536
CrashesPageData
3637
>(request);
3738
const json = await response.json();
38-
const pageData = json.pageData;
39-
const rows = json.rows.map((row) => new CrashesApiRow(row));
39+
40+
if (response.status === 400) {
41+
throw new Error((json as ErrorResponse).message || 'Bad Request');
42+
}
43+
44+
if (response.status === 401) {
45+
throw new Error('Could not authenticate, check credentials and try again');
46+
}
47+
48+
if (response.status === 403) {
49+
throw new Error('Forbidden');
50+
}
51+
52+
const responseData = json as TableDataResponse<CrashesApiResponseRow, CrashesPageData>;
53+
const pageData = responseData.pageData;
54+
const rows = responseData.rows.map((row) => new CrashesApiRow(row));
4055

4156
return {
4257
rows,

src/summary/summary-api-client/summary-api-client.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ApiClient, TableDataClient, TableDataResponse } from '@common';
22
import { SummaryApiResponseRow, SummaryApiRow } from '../summary-api-row/summary-api-row';
33
import { SummaryTableDataRequest } from '../summary-table-data/summary-table-data-request';
4+
import { ErrorResponse } from 'src/common/data/table-data/table-data-client/table-data-client';
45

56
export class SummaryApiClient {
67

@@ -20,8 +21,22 @@ export class SummaryApiClient {
2021
}
2122
const response = await this._tableDataClient.postGetData<SummaryApiResponseRow>(request, formParts);
2223
const json = await response.json();
23-
const pageData = json.pageData;
24-
const rows = json.rows.map(row => new SummaryApiRow(
24+
25+
if (response.status === 400) {
26+
throw new Error((json as ErrorResponse).message || 'Bad Request');
27+
}
28+
29+
if (response.status === 401) {
30+
throw new Error('Could not authenticate, check credentials and try again');
31+
}
32+
33+
if (response.status === 403) {
34+
throw new Error('Forbidden');
35+
}
36+
37+
const responseData = await response.json() as TableDataResponse<SummaryApiResponseRow>;
38+
const pageData = responseData.pageData;
39+
const rows = responseData.rows.map(row => new SummaryApiRow(
2540
row.stackKey,
2641
Number(row.stackKeyId),
2742
row.firstReport,

0 commit comments

Comments
 (0)