Joseph Woolf
Joseph Woolf

Reputation: 550

Azure B2C: Webhook Notifications of User Activity Aren't Being Picked Up

Due to an issue that I've been dealing with Azure B2C, I was thinking of using notification webhooks to receive information on when a user was created/updated.

While I'm able to create a subscription to the users resource, the webhook won't fire off when I actually create/update a user via the Graph API.

I created the subscription as follows:

POST https://graph.microsoft.com/v1.0/subscriptions
{
   "changeType":"updated",
   "notificationUrl":"https://a7500b01de1c.ngrok.io/b2chook/Users",
   "resource":"users",
   "expirationDateTime":"2021-08-09T01:50:17.699528+00:00"
}

The webhook that's listening into the subscription is being done in Python via Flask.

Here's the current code that's written up to receive the webhook notification:

class B2CUserHook(Resource):
    @staticmethod
    def post():
        logger.debug(f"Microsoft Graph API notified the endpoint!")
        if "validationToken" in request.args:
            token = request.args.get('validationToken')
            #res = make_response(token, 201)
            #res.mimetype = "text/plain"
            logger.debug(f"Token to return back to Graph API: {token}")
            return Response(token, mimetype="text/plain")
        
        return Response(status=202)

With the url being declared as a resource:

api.add_resource(user_controller.B2CUserHook, "/b2chook/Users")

So, how exactly can I fix this issue so that I can receive the notification?

Upvotes: 1

Views: 1174

Answers (1)

Jas Suri - MSFT
Jas Suri - MSFT

Reputation: 11335

It says it in the linked document: Azure AD B2C tenants are not supported

Upvotes: 1

Related Questions