Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Connect App using Oauth

(0) ShareShare
ReportReport
Posted on by 105

HI Experts,

I'm currently using a third party app (a simple javascript vuejs) build by our services that connect Users (team members licenced)  to business central in order to write directly their hours to job journal using Odata.

As you already know, it is not possible for team member to insert usage in job journal. 

To workaround this limitation, we did the following that is working fine, using WASK (Web Access Key) to consume OData : 

We have an automated login for an Essential Licensed (WASK is stored in app)

and we have another loggin for the team member, whose, after first loggin, the WAK is stored also in the app.

the app is working like this : 

Team Member, with his own authentication, is serching for Data that belong to himself (job, job planning lines, quantity etc...)

When team member is recording a usage, on click on "Send", the "Writting" Odata Url is sent using the Project Manager Logging ( Essential User), stored in the application, as said before.

The Project manager is able to post the hours daily using a job journal customization that help to see how many hours had been recorded day by day.

Until now, all is working fine.

I want to add here that this way to work was definitvely extremely efficient. Our user are doing a big amount of micro tasking all day (it can be from 10 to 30).

but now that is coming the OAuth Authentication, I'm wondering if this kind of workaround fond  would still be possible.

I cannot imagine now team member access to job journal for inserting data using their project Manager OAuth logging (Essential license)

Thank you for any idea or help.

Hicham

  • Verified answer
    Hicham OE Profile Picture
    Hicham OE 105 on at
    RE: Connect App using Oauth

    Daniele,

    Really perfect, it is working like a charm. Thank you very much for your help.

  • Suggested answer
    Amit_Sharma Profile Picture
    Amit_Sharma 2,545 on at
    RE: Connect App using Oauth

    Hi,

    Adding Info.

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/authenticate-web-services-using-oauth

    Regards

    Amit Sharma

    www.erpconsultors.com
    Press Yes if Info is useful

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: Connect App using Oauth

    Hi

    with the introduction of the Beare Token(OAuth2), authorization to a BC service is no longer tied to a Business central user

    the following link will help you better understand:

    learn.microsoft.com/.../authenticate-web-services-using-oauth

    it is simply a matter of making a double call:

    1 - to retrieve the Bearer Token from the app registration to which Business Central is subscribed.

    2 - to use the bearer token to invoke Business central's exposed REST Service.

    I attach an example:

    CAll TOKEN:

    method:GET

    URL: login.microsoftonline.com/.../token

    In the body of the request:

    grant_type=client_credentials

    client_id= CLient Id app Registration

    client_secret=client secret app registration

    scope= api.businesscentral.dynamics.com/.default

    the call will return you the Beare Token to use in the second call to the business central service:

    URL: api.businesscentral.dynamics.com/.../{My Tenant}/{MyEnviroment}/api/v2.0/companies({IDCOMPANY})/items

    the Header of the call must contain the following KEYs:

    Authorization: Bearer Token - > EXAMPLE(Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9)

    Content-Type: application/json

    Kindest regards,

    DAniele

    My blog: sites.google.com/.../daniele-incalza

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Connect App using Oauth

    Hello,

    I would expect that it will work in a similar way, but you need to rewrite the authentication part. Hope you will receive further suggestions from the hard-core developers available in this forum.

    Thank you.

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

News and Announcements

Announcing Category Subscriptions!

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,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans