# Exchange Authorization Code Per Access Token Exception after authentication

**URL:** <https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [May 13, 2021, 3:08pm UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746 "2021-05-13T15:08:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdi.azure](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pdi.azure/32/25520_2.png) [@pdi.azure](https://community.auth0.com/u/pdi.azure)\
**Post date:** [May 13, 2021, 3:08pm UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746/1 "2021-05-13T15:08:56Z")

</div>

I deployed a new version of our application last night and tested it. This morning when I went to log in, I received the following error message:

# Server Error in ‘/’ Application.

## _Object reference not set to an instance of an object._

**Description:** An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

**Exception Details:** System.NullReferenceException: Object reference not set to an instance of an object.

**Source Error:**

`An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.`

**Stack Trace:**

`[NullReferenceException: Object reference not set to an instance of an object.] Auth0.Client.ExchangeAuthorizationCodePerAccessToken(String code, String redirectUri) +641 Pdi.Ordering.Admin.Web.Controllers.Timestamp.WebApi.Controllers.AuthenticationController.ExternalLogInCallback(String code, String state) in C:\Projects\pdi\src\Pdi.Ordering.Admin.Web\Controllers\AuthenticationController.cs:37 lambda_method(Closure , ControllerBase , Object[] ) +178`

Nothing has changed my end, but the application just doesn’t load any more.

Is there anyone else with a similar experiance?

---

<div class="post-metadata">

**Author:** ![ben15](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben15/32/29482_2.png) [@ben15](https://community.auth0.com/u/ben15)\
**Post date:** [May 18, 2021, 3:00am UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746/2 "2021-05-18T03:00:18Z")

</div>

@pdi.azure I’m having the same issue.  
Did you manage to to fix this?

I’m assuming it has something to do with Azure AD/ADFS connections and the email\_verified setting because something related to that was deprecated May 18th.

---

<div class="post-metadata">

**Author:** ![pdi.azure](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pdi.azure/32/25520_2.png) [@pdi.azure](https://community.auth0.com/u/pdi.azure)\
**Post date:** [May 18, 2021, 8:49am UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746/3 "2021-05-18T08:49:40Z")

</div>

This issue was resolved. The response I had from Auth0 support was:

> An update on this situation; the error situation with the .NET application is most likely being caused by a failure to connect to the service due to the usage of deprecated TLS versions ([Deprecations and Migrations](https://auth0.com/docs/product-lifecycle/deprecations-and-migrations#legacy-tls-deprecation)).
> 
> You can probably quickly force the use of TLS 1.2 by adding this code (System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;) at application startup as that should force TLS 1.2 before any attempt to call into the Auth0 service. However, you may also want to consider retargeting the web application to a .NET Framework that uses TLS 1.2 or above by default in addition to also consider upgrading Auth0 SDK versions.

I hope this resolves your issue as well.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 18, 2021, 9:05am UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746/4 "2021-05-18T09:05:41Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 27, 2021, 11:58am UTC](https://community.auth0.com/t/exchange-authorization-code-per-access-token-exception-after-authentication/62746/5 "2021-05-27T11:58:40Z")

</div>


