I am trying to add Twitter social login for an Azure AD B2C tenant. I followed the below instruction from Microsoft https://learn.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-twitter?pivots=b2c-user-flow
While I try to test the user flow I am getting error as follows.
The request to obtain a token from 'https://api.twitter.com/oauth/request_token' returned an error 'Forbidden'
I have re-created the Twitter credentials just to make sure that this issue is not because of the credentials. I have checked almost everything I can, but the issue remains the same.
Also I can't find any further details about the above error by the correlation id shared by Azure AD. I have checked all the logs available in Azure B2C and I can't find any traces about this error.
I have created a .net sample using the same twitter credentials and the social login works without any issue.
So this issue seems to be something related to Azure B2C specifically. Any pointers for sorting out this issue will be much appreciated.
Thanks
I tried to reproduce the same in my environment and got below results:
I have one user flow named B2C_1_SUSI
where I added Twitter as identity provider before running it like this:
I got login screen including Sign in with your social account after selecting Run user flow
like below:
When I clicked on Twitter
, I got same error as you like this:
The error usually occurs if there is something wrong in added
Callback URI / Redirect URLs
of User Authentication settings page.
As mentioned in this MS documentation,
You need to use all lowercase letters when entering your tenant name and user flow name even if they are defined with uppercase letters in Azure AD B2C.
When I checked the same in Twitter Developer Portal's User Authentication settings page of application, user flow name is in uppercase like below:
https://sritestb2caad.b2clogin.com/sritestb2caad.onmicrosoft.com/B2C_1_SUSI/oauth1/authresp
To resolve the error, I changed user flow name to lowercase as mentioned in the document like this:
https://sritestb2caad.b2clogin.com/sritestb2caad.onmicrosoft.com/b2c_1_susi/oauth1/authresp
After saving it, I ran the userflow again where I got below screen to authorize application like this:
When I clicked on Authorize app
button, it redirected me to User Details page successfully like below:
In your case, check whether you added Callback URI / Redirect URLs
of User Authentication settings page in correct format or not by clicking Edit
button beside it like this: