plugins: migrate usage of deprecated IdentityApi methods
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
|
||||
const baseUrl = `${await this.discoveryApi.getBaseUrl('azure-devops')}/`;
|
||||
const url = new URL(path, baseUrl);
|
||||
|
||||
const idToken = await this.identityApi.getIdToken();
|
||||
const { token: idToken } = await this.identityApi.getCredentials();
|
||||
const response = await fetch(url.toString(), {
|
||||
headers: idToken ? { Authorization: `Bearer ${idToken}` } : {},
|
||||
});
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
|
||||
import { identityApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
|
||||
export function useUserEmail(): string | undefined {
|
||||
const identityApi = useApi(identityApiRef);
|
||||
return identityApi.getProfile().email;
|
||||
const state = useAsync(() => identityApi.getProfileInfo(), [identityApi]);
|
||||
return state.value?.email;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user