0

Is there a way for the components to use the beta endpoint to Microsoft Graph api, example <mgt-people-picker> selectedPeople returns the emails as a ScornedEmailAddress where the beta endpoint returns it as a RankedEmailAddress?

Edit: added my code

<script src=@string.Format("https://unpkg.com/@microsoft/mgt/dist/bundle/mgt-loader.js")></script>

    <script>

        const provider = new mgt.ProxyProvider("https://localhost:44375/api/GraphProxy");
        provider.login = () => window.location.href = '@Url.Action("SignIn", "Account")';
        provider.logout = () => window.location.href = '@Url.Action("SignOut", "Account")';

        provider.graph = mgt.BetaGraph.getGraph(provider);


        mgt.Providers.globalProvider = provider;
    </script>

Edited solution:

<script src=@string.Format("https://unpkg.com/@microsoft/mgt/dist/bundle/mgt-loader.js")></script>

    <script type="module">

        const provider = new mgt.ProxyProvider("https://localhost:44375/api/GraphProxy");
        provider.login = () => window.location.href = '@Url.Action("SignIn", "Account")';
        provider.logout = () => window.location.href = '@Url.Action("SignOut", "Account")';

        provider.graph._version = "beta";


        mgt.Providers.globalProvider = provider;
    </script>
4

1 回答 1

1

Today, the toolkit switches between the beta and v1 endpoint based on the api a component needs to call. In a future release, we intend to separate this into two different packages, one that always calls v1 and one that always calls beta.

In the meantime, you can use the following code when creating a provider to always use beta:

import { Providers, MsalProvider } from '@microsoft/mgt'
import { BetaGraph } from '@microsoft/mgt/es6/BetaGraph.js';

let provider = new MsalProvider({
  clientId: 'a974dfa0-9f57-49b9-95db-90f04ce2111a'
});

provider.graph = BetaGraph.fromGraph(provider.graph);

Providers.globalProvider = provider;

Keep in mind, BetaGraph is an internal class that might change in future releases and is only intended to be used internally.

于 2020-04-28T15:57:18.627 回答