Forum Discussion

  • Umag98 - Hello,
    Have a look at Microsoft Graph Toolkit providers. You can use Custom provider - Microsoft Graph | Microsoft Docs. Let me know if you need any help. 

     

    Thanks, 

    Hunaid Hanfee

    -------------------------------------------------------------------------------------------------------------------------------------------- 

    If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

    • Umag98's avatar
      Umag98
      Brass Contributor

      HunaidHanfee-MSFT 

       

      I tried using the simple provider.
      it is not working as expected.

        provider = new SimpleProvider(async function getAccessTokenhandler(scopesstring[]) {
                              try {
                                  let _accessToken = localStorage.getItem("accessToken");
                                  if (_accessToken) {
                                      return _accessToken;
                                  }
                                  
                              } catch (error) {
                                  console.log(error);
                                  return error;
                              }
                          });
                          Providers.globalProvider = provider;
                          Providers.globalProvider.setState(ProviderState.SignedIn);
       
      and i am trying to call the People picker
      <div>
                  {gotAccessToken && <div><PeoplePicker {...props.pickerType === "person" ? { type: PersonType.person } :
                      { ...props.pickerType === "group" ? { type: PersonType.group } : { type: PersonType.any } }} {...props.isPickerDisabled ? { disabled: true } : undefined}
                      defaultSelectedUserIds={defaultPickerValue} selectionMode={props.selectionMode} selectionChanged={handleSelectionChanged} />
                      {props.toShowSelectedPeople && <div>Selected People: <People people={people} /></div>}</div>}
                  {!gotAccessToken && <Spinner label="Loading..." ariaLive="assertive" labelPosition="left" />}
              </div>
       
      The accessToken i am getting from the asp.net web api,


      with which i am able to call graph apis. in the asp.net core webapi.
      i am using the same here, but it is not working.
      this is the error I get when i try to do it
      1. error: {code: "InvalidAuthenticationToken", message: "Access token validation failure. Invalid audience.",…}
        1. code: "InvalidAuthenticationToken"
        2. innerError: {date: "2021-08-24T08:27:14", request-id: "494c6420-fedc-4314-b71f-2f8e188a38c1",…}
        3. message: "Access token validation failure. Invalid audience."
      • Umag98 - Looks like your configuration is wrong for token validation "audience".
        Could you please reverify & test it again.

Resources