Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

I want to code an authentication interface on Microsoft dynamic center

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans