cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fer_vd
Frequent Visitor

Api example to MVC

Hi, I used the example "integrate report into webapp" and this works. But now i'm trying to get this code into a MVC structure and i'm getting errors from the redirect. I have installed the package for using Microsoft.IdentityModel.Clients.ActiveDirectory, but the following gives an error:

AuthenticationResult AR = AC.AcquireTokenByAuthorizationCode(code, new Uri(redirectUri), cc);

 

It can't find the AcquireTokenByAuthorizationCode(code, new Uri(redirectUri), cc); method.

Does anybody have an idea how to solve this?

1 ACCEPTED SOLUTION
fer_vd
Frequent Visitor

Alright.. so after a lot of try and error I found out the method AcquireTokenByAuthorizationCode is no longer supported in the new versions of Microsoft.IdentityModel.Clients.ActiveDirectory. I now tried version 2.22 which works. The example uses v2.19.

In newer versions it is needed to use AcquireTokenByAuthorizationCodeAsync.

View solution in original post

5 REPLIES 5
v-chuncz-msft
Community Support
Community Support

@fer_vd,

 

According to your description, it seems to be an issue of ambiguous class name. Try to use the fully qualified name(Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext).

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi thanks for your reply.

 

I added the full name now, but it makes no difference.

Naamloos.png

fer_vd
Frequent Visitor

Alright.. so after a lot of try and error I found out the method AcquireTokenByAuthorizationCode is no longer supported in the new versions of Microsoft.IdentityModel.Clients.ActiveDirectory. I now tried version 2.22 which works. The example uses v2.19.

In newer versions it is needed to use AcquireTokenByAuthorizationCodeAsync.

View solution in original post

i have same error i change to to use AcquireTokenByAuthorizationCodeAsync but i will have this error An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>.

i have the same error when i use AcquireTokenByAuthorizationCodeAsync i will have this error An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.