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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Get token with d365fo.tools

(0) ShareShare
ReportReport
Posted on by 100
Dear experts,
I want to use PowerShell to execute some scripts, so I installed d365fo.tools.
When I use the command Get-D365LcsApiToken to get the access token, an error always appears:The remote server returned an error: (401) Unauthorized.
I have checked the parameters several times without finding any problems, I don't know where the problem lies.
I have disabled the user's MFA authentication.
 
The commands to be executed are as follows:
Get-D365LcsApiToken -ClientId "b1ff7cb5-****-********" -Username "*****@*****.onmicrosoft.com" -Password "********" -LcsApiUri "https://lcsapi.lcs.dynamics.com" -Verbose | Set-D365LcsApiConfig -ProjectId "******" -ClientId "b1ff7cb5-****-********"
Categories:
I have the same question (0)
  • Sohaib Cheema Profile Picture
    47,766 User Group Leader on at
    Get token with d365fo.tools
     
    click on the middle tab (Manage - API Permissions tab) and then search for Dynamics Lifecycle services
     
     
  • Hu, Ethan Profile Picture
    100 on at
    Get token with d365fo.tools
    I have added the Microsoft Graph>User.Read.
    I can't find Dynamics LCS from the API list.
    I have tried deleting the second client id parameter, but it did not work.
  • Sohaib Cheema Profile Picture
    47,766 User Group Leader on at
    Get token with d365fo.tools
    I wonder if you added the permissions on the Azure Registered app (Dynamics LCS>Service user_impersonation , Microsoft Graph>User.Read)
    Also did you notice you are passing client id twice which is not needed.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 775 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 634 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 622 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans