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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Catering for a redirect URL with parameters

(0) ShareShare
ReportReport
Posted on by 3,542

Hi folks

So I am working on a LinkedIn integration. I am stuck at the point where I need to accept an access token at a redirect URI: LinkedIn Authorization.

I will describe it as I understand. After successful authorization LinkedIn will call a URL somewhere someplace. For now I created a service in AX and specified that LinkedIn should call this service/URL/URI.

So the dev looks like this:

  • Service Group - LinkedInTestGroup
  • Service - LinkedInTest
  • Class - LinkedInTest
  • Method - hello(str code, str state)

void hello(str code, str state)
{
    Table1 hello;
    hello.Wanneer = DateTimeUtil::utcNow();
    hello.Hello = "hello";
    hello.insert();
}

So after successful authorization (which I do with Postman at the moment) there should be a record in Table1 (it's cross company). But there isn't. I don't know if the method gets hit at all.

In summary: I need to accept a token. I don't know how. I am trying a service. But it does not work and I don't know why.

Maybe one piece of useful information is that if I call my service from the browser, I get this:

Screenshot-2020_2D00_05_2D00_10-at-16.10.57.png

Thanks for your attention

I have the same question (0)
  • Rahul Mohta Profile Picture
    21,032 on at

    using an Azure token to authenticate

  • Suggested answer
    Pete Alberts Profile Picture
    3,542 on at

    Rahul your response is not helpful at all. I assume this is due to a language barrier.

    I thought I'd supply the solution to some other developer that finds himself in this scenario.

    1. This is general Oath2. Maybe broader, not sure.
    2. A redirect URL is a redirect URL. After the user successfully logs in, he needs to go somewhere. Meaning a form and not a service.
    3. In the auth request that directs the user to the login page (of LinkedIn in this case) you can specify the RedirectURL. For LinkedIn you cannot add query parameters to the Redirect URL registration. Which is a problem in AX (the problem is why I tried using a service, which comes down to only a path). But you can add the query parameters in the actual auth request. Meaning you register a redirectURL as https://usnconeboxax1aos.cloud.onebox.dynamics.com but in the auth request you specify the RedirectURL as https://usnconeboxax1aos.cloud.onebox.dynamics.com/?mi=MyRedirectForm.
    4. Then you need to get the security info. Which means you'll need to get the current request (in code). There are enough resources on that. You can start by looking at SysClassRunner. If you do not manage there, you can have a look at URLUtility (x++ class) and after that you'll need to use dotNet. System.Web.HttpContext::Current.Request is a good place to start.

    Some additional information

    • This type of integration will work on an on-prem installation. If we take usnconebox as an example. LinkedIn (or some other site) cannot access it as it isn't public. But that is no problem as the original auth request will have been sent from a browser that does indeed have access to the VM. Meaning the non-public redirect URL is accessible from that browser. I don't know how to word that better.
    • LinkedIn only takes a single parameter in the redirectUrl. Which is a problem if your integration is company specific (once redirected the session will default to the users default DatAreaId). I solved this by adding the company in my "state" parameter. Then you need to split it again (from the actual security code you generated) at the redirect page using some string handling. Lastly, you obviously need to change that session to the DataArea you received.
    • I find it reasonable to assign the redirectURL menu item and the original auth request's form's menu item to the same security privilege.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans