Skip to content

Commit 9943abe

Browse files
committed
fixed orcid work service methods
1 parent 9749cb9 commit 9943abe

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/orcid/orcid-user.service.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ export class OrcidUserService {
5656
*/
5757
public revokeAuth = async (orcid: string): Promise<void> => {
5858
try {
59-
const response = await fetch(`rsc/orcid/oauth/${orcid}`, {
60-
method: 'DELETE',
61-
headers: {
62-
...this.getAuthHeaders(),
63-
},
64-
});
59+
const response = await fetch(
60+
new URL(`rsc/orcid/oauth/${orcid}`, this.baseUrl),
61+
{
62+
method: 'DELETE',
63+
headers: {
64+
...this.getAuthHeaders(),
65+
},
66+
}
67+
);
6568
ensureOk(response);
6669
} catch (error) {
6770
throw handleError(error, 'Failed to revoke ORCID');

src/orcid/orcid-work.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class OrcidWorkService {
4747
this.getUrl(`${mode}/${orcid}/works/object/${objectId}`),
4848
{
4949
headers: {
50+
...this.getAuthHeaders(),
5051
Accept: 'application/json',
5152
},
5253
}
@@ -77,6 +78,7 @@ export class OrcidWorkService {
7778
const response = await fetch(
7879
this.getUrl(`member/${orcid}/works/object/${objectId}`),
7980
{
81+
...this.getAuthHeaders(),
8082
method: 'POST',
8183
}
8284
);
@@ -94,4 +96,8 @@ export class OrcidWorkService {
9496
private getUrl(path?: string): URL {
9597
return new URL(path ? `${API_PATH}/${path}` : API_PATH, this.baseUrl);
9698
}
99+
100+
private getAuthHeaders(): Record<string, string> {
101+
return this.authStrategy?.() ? this.authStrategy().getHeaders() : {};
102+
}
97103
}

0 commit comments

Comments
 (0)