I want to code an authentication interface on Microsoft dynamic 365 business center

Copper Contributor
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


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 := 'Email address removed';
pwd := '******';
ResourceURL := 'https://api.businesscentral.dynamics.com/';
// //Environment := authTable.Environment;
// OAuth2.GetDe...

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

MicrosoftOAuth2Url := 'https://login.microsoftonline.com/ec61defb-c499-4bae-afbe-e96c06b43964/oauth2/v2.0/authorize'; //TOK...
https://login.microsoftonline.com/common/adminconsent';
Scopes.Add('api://ed48ea31-f9d3-40aa-b7d7-ad3...






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;

 

}

 

0 Replies