msgraph-sdk-javascript icon indicating copy to clipboard operation
msgraph-sdk-javascript copied to clipboard

Create a setter for baseUri

Open nmetulev opened this issue 3 years ago • 7 comments

Feature Request

Add the ability to set the baseUri of the graph client after the client has been initialized. This will make it easier to change the baseUri of the graph client in scenarios where the developer might not own the code that initializes the graph client (such as the Microsoft Graph Toolkit)

Describe the solution you'd like

const client = MicrosoftGraph.Client.init(...);

client.baseUri = 'https://graph.microsoft-ppe.com';

// or
client.setBaseUri('https://graph.microsoft-ppe.com');

Additional context

Request coming out of a request on the Microsoft Graph Toolkit to support additional baseUris:

https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1053 https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1030

AB#9222

nmetulev avatar Apr 29 '21 23:04 nmetulev

@nmetulev Thank you for this feature request!

Adding to the description of this issue, we should discuss providing ways to modify the other client configs after the client is initialized.

nikithauc avatar Apr 29 '21 23:04 nikithauc

Agree 💯

nmetulev avatar Apr 30 '21 00:04 nmetulev

My concerns:

  • Authentication tokens are tied to a host URI and by changing the base URI the token will no longer be valid. At least that's my understanding.
  • We advise developers to create one client per host + endpoint. The API surface and behavior can change between hosts and endpoints which can lead to unexpected results. For this reason we discourage changing the base URI.
  • (hypothetical) Middleware has the potential to be keyed to a specific cloud. For example, logging requests to some cloud service. It could trigger a compliance event.

MIchaelMainer avatar Jul 09 '21 20:07 MIchaelMainer

Does anyone know if this issue is being picked up by MSFT or is it waiting to be fixed by the community?

jimmywim avatar Sep 30 '21 12:09 jimmywim

@jimmywim This request will need some some more discussion with the Graph SDK team.

I would like to know what is your take on this issue?

nikithauc avatar Oct 01 '21 21:10 nikithauc

@nikithauc No worries, would be good to know if this is on the timeline to be implemented or not.

Any solution that uses this SDK to communicate to MS Graph (for example Microsoft Graph Toolkit) is not currently portable to any National Cloud instances of Microsoft 365 (including GCC and Germany).

jimmywim avatar Oct 06 '21 14:10 jimmywim

@jimmywim The Graph JS SDK works with the National Cloud instances, that is, "graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de", "microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com"

Please let me know if the case is otherwise.

nikithauc avatar Jan 31 '22 07:01 nikithauc

Was delivered as part of v3. Closing.

sebastienlevert avatar Jul 25 '23 15:07 sebastienlevert