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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Getting a valid Bearer Token from sharepoint in NAV 17

(0) ShareShare
ReportReport
Posted on by 20

Hello Experts,

Can you please help me to downgrade this Business Central AL Code to NAV17 ?

procedure GetToken() Token: text
    Var
        TypeHelper: Codeunit "Type Helper";
        client: HttpClient;
        cont: HttpContent;
        header: HttpHeaders;
        response: HttpResponseMessage;
        Jobject: JsonObject;
        tmpString: Text;
        granttype: text;
        clientid: text;
        ClientSecret: text;
        resources: text;
        RequestURI_L: Text;
        Jtoken: JsonToken;
        ResponseText: Text;
        tenant: Text;
    Begin
        SharepointSetup_L.Get(UserId);
        granttype := SharepointSetup_L."Grant Type";
        clientid := SharepointSetup_L.Client_Id   '@'   SharepointSetup_L.Tenant;
        ClientSecret := SharepointSetup_L."Client Secret";
        resources := SharepointSetup_L.Resources   '/'   SharepointSetup_L.Domain   '.sharepoint.com@'   SharepointSetup_L.Tenant;
        cont.WriteFrom('grant_type='   TypeHelper.UrlEncode(granttype)   '&client_id='
          TypeHelper.UrlEncode(clientid)   '&client_secret='   TypeHelper.UrlEncode(ClientSecret)
          '&resource='   TypeHelper.UrlEncode(resources)   '');
        cont.GetHeaders(header);
        header.Add('charset', 'UTF-8');
        header.Remove('Content-Type');
        header.Add('Content-Type', 'application/x-www-form-urlencoded');
        RequestURI_L := 'https://accounts.accesscontrol.windows.net/'   SharepointSetup_L.Tenant   '/tokens/oAuth/2';
        client.Post(RequestURI_L, cont, response);
        response.Content.ReadAs(ResponseText);
        Jobject.ReadFrom(ResponseText);
        Jobject.Get('access_token', Jtoken);
        Token := Jtoken.AsValue().AsText();
    end;

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    98,574 Super User 2026 Season 1 on at

    Hi, hope the following can give you some hints.

    How can I get an access token from from Azure AD using NAV2017 — mibuso.com

    Thanks.
    ZHU

  • zizousa2 Profile Picture
    20 on at

    Thank you but can you help me to convert this code into C/AL NAV17 please, it will be used to generate a valid Bearer Access Token from Sharepoint to use it to list Sharepoint Library Files list in Navision Item Card in a spesific Listpart

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,822 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,136 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 956 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans