Badgr Custom Connector for Power Automate

In my previous post, I mentioned that there is a great Badgr template app available for Teams, but this cannot directly connect with Slack. My solution is to use a custom Power Automate connector to assign badges and then post the notification message in Slack (the user will receive an email from Badgr after the badge is assigned).

Before I go into the steps needed to create the custom connector, you can also skip these by importing my development Swagger export which has other actions I've been testing (submit an issue if you find one).

Badgr provides a great resource for creating any app using OAuth 2.0 and you'll need to request an application key before getting started. Look at the Badgr API before submitting your request to determine which scopes you'll need, but for this example you need r:profile rw:issue.

In Power Automate, start you custom connector by adding an icon (the Badgr badger is awesome) and set Host to api.badgr.io and Base URL to /V2.

brave_ssb4T5M345.png

For security, I've already mentioned we'll be using OAuth 2.0, so you'll need both client ID(application key) and client secret from Badgr. Authorization URL is badgr.com/auth/oauth2/authorize and Token/Refresh URL is api.badgr.io/o/token.

brave_nlaabbC32I.png

Be sure to copy the Redirect URL after you save the connector. In the Definitions step, I suggest you add two actions: /users/self to quickly test the connector and /badgeclasses/{entity_id}/assertions to assign an assertion(badge) to a user. For getting your Badgr info, you just need to import a sample GET with no additional path or queries:

brave_ec3YndRyl2.png

For the POST for assigning an assertion, you will need to add curly brackets in the body as we will be using this in the action:

brave_3hC3dJ7hPt.png

You can now save this connector. Add a new connection in the Test step and test the /users/self to make sure that you are getting a 200 response. If you get a 40x response, you probably didn't ask Badgr to assign the correct scopes to the application key.