web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to generate a user...
Power Apps
Suggested Answer

How to generate a user token in Canvas Apps PCF Control

(2) ShareShare
ReportReport
Posted on by 4
Hi Team,
 
I'm building a Canvas Apps PCF control to integrate with a custom Teams channel chatbot (developed by ServiceNow). This integration requires a user token. Considering OAuth 2.0 and MSAL, which is the recommended and supported method for user token acquisition within a Canvas Apps PCF control for this scenario?
I have the same question (0)
  • Suggested answer
    Inogic Profile Picture
    1,269 Moderator on at
    Hi,

    For a Canvas Apps PCF control, the best and supported way is to use MSAL (Microsoft Authentication Library) with OAuth 2.0 (Entra ID) to get the user token.

    PCF controls don’t handle login by themselves, so you need to use MSAL to sign in the user and get the token.

    What to do:

     
    • Register your app in Entra ID (Azure AD)
    • Use MSAL.js inside your PCF control
    • Let the user sign in (popup or redirect)
    • Get the access token and send it to your chatbot
    • If possible, use a backend:
      • PCF → call your API
      • API → handles token and talks to ServiceNow

    Hope this helps!
     
    Thanks!
    Inogic
  • CU23041916-0 Profile Picture
    4 on at

    Thanks for the guidance. I’ve already implemented the same approach using MSAL.js inside the PCF control and tested it in both desktop and mobile scenarios.


    • Desktop (laptop browser): MSAL sign-in works and I’m able to successfully acquire the user access token.

    • Mobile (Power Apps mobile): after entering credentials, the flow redirects to the device browser and the authentication does not complete back inside the app. Because of this, the token is not being generated/returned to the PCF control.

    From our earlier troubleshooting, it appears this behavior may be related to redirect URI / platform configuration (e.g., using the https://apps.powerapps.com/play/...<guid> redirect URI and ensuring it’s set under SPA, not Web) and/or mobile browser access restrictions enforced by corporate policy, which can block Power Apps auth completion on mobile browsers.

    If you have any recommended approach specifically for mobile Power Apps  (e.g., best practice redirect setup or alternate MSAL flow that works reliably on mobile), please share.

     

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 556

#2
WarrenBelz Profile Picture

WarrenBelz 412 Most Valuable Professional

#3
Haque Profile Picture

Haque 296

Last 30 days Overall leaderboard