Skip to main content

Notifications

Announcements

No record found.

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
    Marco Mels 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,419 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,492 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans