Azure Function APP Authentication & trigger this azure Function in SPFx webpart
Identity providers
App Service uses federated identity, in which a third-party identity provider manages the user identities and authentication flow for you. Five identity providers are available by default:
Reference Link :
https://docs.microsoft.com/en-us/azure/app-service/overview-authentication-authorization
and Call above function in SPFx webpart as below
public async _makeAzureCMRequest(): Promise<string>{
return new Promise<string>((resolve, reject) => {
const body: string = JSON.stringify({
'_siteUrl': this.spfxContext.pageContext.web.absoluteUrl,
'_pageItemID':this.spfxContext.pageContext.listItem.id
});
const requestHeaders: Headers = new Headers();
requestHeaders.append('Content-type', 'application/json');
requestHeaders.append('Cache-Control', 'no-cache');
const httpClientOptions: IHttpClientOptions = {
body: body,
headers: requestHeaders
};
this.spfxContext.aadHttpClientFactory
.getClient(strings.clientId)
.then((client: AadHttpClient): void => {
client
.post(strings.azureContentAPI, AadHttpClient.configurations.v1,httpClientOptions)
.then((response: SPHttpClientResponse) => response.json())
.then((response: any) => {
if (response) {
console.log(response)
let varitems =response.Result;
resolve(varitems)
console.log(response.Row);
}
});
});
});
No comments:
Post a Comment