Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

I want to code an authentication interface on Microsoft dynamic center

(0) ShareShare
ReportReport
Posted on by 5

[9:59 AM] Salma Bouzeida

I did all the linking steps between microsoft azure and microsoft dynamic. I found this code, I assumed that this function is the desired function. but when i ran the code it gave me an empty token. I don't know where the fault is! please help me

the code : 

page 50148 "testaccestoken"
{
PageType = Card;
ApplicationArea = All;
UsageCategory = Administration;

layout
{
area(Content)
{
group(GroupName)
{
field(UserEmail; UserEmail)
{
ApplicationArea = All;

}
field(PWD; PWD)
{
ApplicationArea = All;

}
field(AccessToken; AccessToken)
{
ApplicationArea = All;

}
}
}
}

actions
{
area(Processing)
{
action(Token)
{
ApplicationArea = All;
Image = TestFile;
trigger OnAction()

begin
AadTenantId := '*******';
Client_Id := '*******';
UserEmail := 'Salma.bouzeida@vaganet.fr';
pwd := '******';
ResourceURL := 'api.businesscentral.dynamics.com/';
// //Environment := authTable.Environment;
// OAuth2.GetDefaultRedirectURL(RedirectURL);
ClientSecret := '********';

// ** DEFAULT VALUES - redirect and
RedirectURL := 'businesscentral.dynamics.com/OAuthLanding.htm';
// Client_Id := '********';// powershell ID default

MicrosoftOAuth2Url := 'login.microsoftonline.com/.../authorize'; //TOKEN
//OAuthAdminConsentUrl := 'login.microsoftonline.com/.../adminconsent';
Scopes.Add('api://**********/user_impersonation');
OAuth2.AcquireTokensWithUserCredentials(MicrosoftOAuth2Url, Client_Id, Scopes, UserEmail, pwd, AccessToken, idToken);
//Oauth2.AcquireTokenWithClientCredentials(Client_Id, ClientSecret, MicrosoftOAuth2Url, RedirectURL, ResourceURL, AccessToken);
Message(AccessToken);
end;
}
}
}

var
ClientSecret: Text;
RedirectURL: text;
MicrosoftOAuth2Url: text;
OAuthAdminConsentUrl: text;
Scopes: List of [Text];
ResourceURL: Text;
Client_Id: text;
UserEmail: text;
AccessToken: text;
idToken: text;
AadTenantId: Text;
Oauth2: Codeunit OAuth2;
OAuth2Authorization: Codeunit "OAuth 2.0 Mgt.";
PWD: Text;

}

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: I want to code an authentication interface on Microsoft dynamic center

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans