Skip to content

AcquireOBOToken failing when editing SharePoint page within Teams tab #9767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 9 tasks
jacksonv1lle opened this issue Jun 25, 2024 · 1 comment
Open
1 of 9 tasks
Assignees
Labels
Needs: Triage 🔍 Awaiting categorization and initial review. sharepoint-developer-support sharepoint-developer-support type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@jacksonv1lle
Copy link

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • SPFx version - 1.19.0
  • Node.js version - v18.19.1
    MS Teams for web and SPFx

Describe the bug / error

When viewing a SharePoint page within an MS Teams tab, http requests made after switching the page to edit mode are failing

Requests are made using the MSGraphClientFactory provided in the @microsoft/sp-http package.

This package automatically acquires a token from the SharePoint api endpoint AcquireOBOToken providing a clientId. The problem is that the clientId changes to 08e18876-6177-487e-b8b5-cf950c1e598c (SharePoint Online Web Client Extensibility) when you edit the SharePoint page. This results in the token aquisition failing (Similar to this bug)

Upon refreshing the iframe, the web part displays correctly again.

I have tried the steps outlined in this bug to re-generate the secret

Steps to reproduce

  1. Create a standard ReactJS SPFx webpart

  2. Install @microsoft/sp-http library in the package

  3. In the React component, make a request to the Graph API

     import * as React from 'react';
     import type { IHelloWorldProps } from './IHelloWorldProps';
     import { MSGraphClientFactory } from '@microsoft/sp-http';
    
     export default class HelloWorld extends React.Component<IHelloWorldProps, {email:string}> {
       constructor(props:IHelloWorldProps){
         super(props);
         this.state = {
           email: ""
         };
       }
       public componentDidMount(): void {
         const { serviceScope } = this.props;
         serviceScope.whenFinished(async ()=>{
           const msGraphClientFactory = serviceScope.consume(MSGraphClientFactory.serviceKey);
           const msGraphClient = await msGraphClientFactory.getClient('3');
           const me = await msGraphClient.api(`/me`).get();
           this.setState({
             email: me.mail
           });
         });
       }
       public render(): React.ReactElement<IHelloWorldProps> {
         return (
           <div>
             {this.state.email && <p>Your email is {this.state.email}</p>}
           </div>
         );
       }
     }
    
  4. Build, Bundle & Package the solution and upload to the app catalog

  5. Add the web part to the homepage of a SharePoint site connected to a Teams channel

  6. View the page in MS Teams and observe expected behvaiour - the email address is displayed

Screenshot 2024-06-17 111940

  1. Edit the page and then save the page
  2. Observe the email address is no longer displaying as expected

Screenshot 2024-06-17 111956

Expected behavior

The request should continue to work when editing a page

@jacksonv1lle jacksonv1lle added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Jun 25, 2024
@VesaJuvonen VesaJuvonen added the Needs: Triage 🔍 Awaiting categorization and initial review. label Jun 25, 2024
@Ashlesha-MSFT Ashlesha-MSFT self-assigned this Jun 13, 2025
@Ashlesha-MSFT Ashlesha-MSFT added the sharepoint-developer-support sharepoint-developer-support label Jun 13, 2025
@Ashlesha-MSFT
Copy link

Hello @jacksonv1lle,
Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Awaiting categorization and initial review. sharepoint-developer-support sharepoint-developer-support type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

3 participants