Pnpjs: @pnp/graph add support for sovereign clouds

Created on 16 Jul 2020  路  4Comments  路  Source: pnp/pnpjs

Category

  • [X] Enhancement
  • [ ] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [ 2.0.6 ]

Please specify what version(s) of SharePoint you are targeting: [ SPO ]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

Currently the PnP Graph client does not support sovereign cloud tenants. Many graph routes in GCC tenants will fail when ".us" is not used.

Observed Behavior

Graph client does not respect endpoint when given webpart context. It appears to always use ".com".

Steps to Reproduce

In GCC High tenant

    const client = await this.context.msGraphClientFactory.getClient();
    const res1 = await client.api('/me').get();
    // Correctly uses endpoint "graph.microsoft.us"
    graph.setup({
      spfxContext: this.context
    });
    const res2 = await graph.me();
    // Incorrectly uses endpoint "graph.microsoft.com"
   // Notice the .us domain is NOT used.
code complete enhancement

Most helpful comment

Thank you so much!

All 4 comments

This is a great issue, thanks for bringing it to our attention. We are going to aim on having this in the August release to give us time to test it out so we don't break existing deployments. Thanks again for reporting it!

Thank you! This will help us immensely.

This work is done and sitting in PR #1303 awaiting merging. Will be in 2.0.8 in August. You can see the updated docs articles there on how to handle it. Short answer:

  • We added a baseUrl property for graph config - works just like the one in sp you just need to set https://graph.microsoft.us for that value
  • We included logic when working in SPFx to try and get that url automatically from the SPFx context. This works for me in latest SPFx ("on my machine") but unsure on all versions so I included the baseUrl option as well.

baseUrl always takes precedence over any other url logic. Whatever you set there will be used for all requests.

Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings