Skip to main content

Notifications

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;

  • zizousa2 Profile Picture
    20 on at
    RE: Getting a valid Bearer Token from sharepoint in NAV 17

    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

  • Suggested answer
    YUN ZHU Profile Picture
    84,346 Super User 2025 Season 1 on at
    RE: Getting a valid Oauth2 Token in NAV 17

    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

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 > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,452

#2
YUN ZHU Profile Picture

YUN ZHU 1,313 Super User 2025 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 1,083 Most Valuable Professional

Featured topics

Product updates

Dynamics 365 release plans