Network Request Failed Error when fetching token in Azure B2C – Microsoft Q&A

Hello,

I have been trying to integrate authorization and authentication using azure ad b2c in a react native app. I am successfully able to get the authorization code, but the trying to get the access tokens results in ‘Network Request Failed’ error.

I am using fetch() to make HTTP (https) request which have been constructed according to the details here – https://learn.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow
If I copy and paste the url I am passing to fetch() in a browser, it returns a response with access token. However, the same url throws error in the react native fetch().

I have double checked that it is not an issue with fetch() itself. I am able to call some public APIs on https and get the expected response. So the url works in a browser, and fetch() woks in the app, but the url and fetch do not work together in the app.

Any clues as to how to solve this would be appreciated.

Thanks!

EDIT:
Platform: Android
Tried the exact same code in a separate JS environment reusing a recently obtained authorization code, and it returns the token too. So there shouldn’t be any issue in the fetch statement.