Search code examples
twitter-oauthazure-ad-b2c-custom-policyazure-ad-b2c

Azure B2C social logon with Twitter - AuthorizationError


I am setting up Twitter as a social login option following this doc reference on auto-account-link policies. It's been quite some time since I've finished the policy side but keep consistently getting the authorization error below:

correlationId: 1bb357d5-ecdc-437f-97cb-9958ac5940f3

{
    "Key": "OAuth1RequestInfo",
    "Value": {
        "TechnicalProfileId": "Twitter-OAuth1-SignIn",
        "AccessTokenEndpoint": "https://api.twitter.com/oauth/access_token",
        "AuthorizationEndpoint": "https://api.twitter.com/oauth/authenticate",
        "CallbackUri": "https://<tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/b2c_1a_accountlink_susi/oauth1/authresp",
        "ClientId": "aDNZQ1dZTlJEZjFGUXBzb0ZfY1U6MTpjaQ"
    }
},
{
    "Key": "AuthorizationError",
    "Value": "The call to https://api.twitter.com/oauth/request_token for a request token of aDNZQ1dZTlJEZjFGUXBzb0ZfY1U6MTpjaQ returned an error Unauthorized"
}

Things I've tried:

  • Reset client secret and app Id;
  • Make sure there is no typo while pasting secret on policy keys;
  • Enabled Oauth1 and Oauth2 on the Twitter side
    • The docs say Oauth2 should be enabled but on policy call back there is a reference to oauth1.
  • Make sure the callback URL is set correctly.
  • Set Single Page App as the app type (assuming this is correct for my use case)

image

Appreciate your input!


Solution

  • After an issue opened with MS docs they've got it updated, as follows:

    If you're facing unauthorized error while testing this identity provider, make sure you use the correct Twitter API Key and API Key Secret, or try to apply for elevated access. Also, we recommend you've a look at Twitter's projects structure, if you registered your app before the feature was available.