Show
Requirements
Run your site with public access and HTTPS (use ngrok or similar).
2 different accounts set up on https://test.badgr.com/ . Be careful because this is a different account than the ones in Badgr.io used previously in other issues. Here, the accounts need to be created in https://test.badgr.com/ .
Confirm you sing out from https://test.badgr.com/.
Setup OAuth2 service for Badgr
Register the oAuth2 service in the Badgr.io Testing service executing the following command, replacing "https://193f66f5407e.ngrok.io/" by your server URL. You'll probably need to adapt "https://193f66f5407e.ngrok.io/m/stable_master/" to your Moodle URL:
curl --location --insecure --request POST 'https://api.test.badgr.com/o/register' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '
{
"client_name": "Badge Moodle",
"client_uri": "https://193f66f5407e.ngrok.io/",
"logo_uri": "https://193f66f5407e.ngrok.io/m/stable_master/pix/f/moodle-256.png",
"tos_uri": "https://193f66f5407e.ngrok.io/",
"policy_uri": "https://193f66f5407e.ngrok.io/",
"software_id": "stablemaster-testing",
"software_version": "2020041700.01",
"redirect_uris": [
"https://193f66f5407e.ngrok.io/m/stable_master/admin/oauth2callback.php"
],
"token_endpoint_auth_method": "client_secret_basic",
"grant_types": [
"authorization_code",
"refresh_token"
],
"response_types": [
"code"
],
"scope": "https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.readonly https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.create https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.readonly"
}'
You should get a result like this. Copy the client_id and the client_secret (you'll need them to configure the oAuth2 service)
{"client_id":"9ofl140KfgS54uIxbu2zv3v2xqO4EopdSvc02nqV","client_secret":"vsosCajNKEeT9ou9Z0eCRt0nMTsSF9UST2U46v2DJqv42BrZNrh05w8SY95a4lhi07i8z2hCMFzvrlrpFngdAHpWgrdTbGVZAb6rGDZPVBcbQx3NaPYdiB22jt2N7FvQ","client_id_issued_at":1603219589,"client_secret_expires_at":0}
Run the following SQL query to create the OAuth2 issuer. You'll need to replace clientid and client secret by the previous proper values:
INSERT INTO "mdl_oauth2_issuer" ("timecreated", "timemodified", "usermodified", "name", "image", "baseurl", "clientid", "clientsecret", "loginscopes", "loginscopesoffline", "loginparams", "loginparamsoffline", "alloweddomains", "scopessupported", "enabled", "showonloginpage", "basicauth", "sortorder", "requireconfirmation") VALUES
(1611829185, 1611829186, 2, 'IMS OBv2.1 - Badgr', 'https://api.test.badgr.com/static/images/logo.png', 'https://api.test.badgr.com/', 'REPLACE_THIS_BY_CLIENTID', 'REPLACE_THIS_BY_CLIENTSECRET', 'openid profile email', 'openid profile email', '', '', '', 'https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.readonly https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.create https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.readonly', 1, 0, 0, 3, 1);
Run the following SQL query to get the issuer id you've just created:
SELECT id FROM mdl_oauth2_issuer WHERE baseurl='https://api.test.badgr.com/'
Run the following SQL query to configure enpoints for OAuth2 issuer. You'll need to replace issuerid by the previous proper values:
INSERT INTO "mdl_oauth2_endpoint" ("timecreated", "timemodified", "usermodified", "name", "url", "issuerid") VALUES
(1611829186, 1611829186, 2, 'token_endpoint', 'https://api.test.badgr.com/o/token', REPLACE_THIS_BY_ISSUERID),
(1611829186, 1611829186, 2, 'authorization_endpoint', 'https://test.badgr.com/auth/oauth2/authorize', REPLACE_THIS_BY_ISSUERID),
(1611829186, 1611829186, 2, 'registration_endpoint', 'https://api.test.badgr.com/o/register', REPLACE_THIS_BY_ISSUERID),
(1611829186, 1611829186, 2, 'privacypolicy_endpoint', 'https://badgr.com/privacy-policy.html', REPLACE_THIS_BY_ISSUERID),
(1611829186, 1611829186, 2, 'termsofservice_endpoint', 'https://badgr.com/terms-of-service.html', REPLACE_THIS_BY_ISSUERID),
(1611829186, 1611829186, 2, 'discovery_endpoint', 'https://api.test.badgr.com/.well-known/badgeconnect.json', REPLACE_THIS_BY_ISSUERID);
Setup Backpack for Badgr
Go to "Site administration / Badges / Badges settings".
Set the "Badge issuer email address" to the email address of one of the Badgr.io accounts and Save changes.
Go to "Site administration / Badges / Manage backpacks".
Click the "Add a new backpack" button and create a new backpack with the following information:
Backpack API URL: https://api.test.badgr.com/
Backpack URL: https://test.badgr.com/
API version supported: Open Badges v2.1
OAuth2 services: IMS OBv2.1 - Badgr
Save changes.
Go to "Site administration / Badges / Backpack settings" and set the site backpack to https://test.badgr.com/.
Testing scenario: Connect to Badgr.io backpack
Log in as teacher (t1).
Go to Dashboard / Preferences / Badges / Backpack settings.
Check https://test.badgr.com/ " is the "Backpack URL" or "Backpack provider", depending on the Moodle version. From Moodle 3.10 you should be able to change it (although ihttps://test.badgr.com/ should be displayed by default).
Check the "Status" is "not connected" and the button "Connect to backpack" appears.
Click button "Connect to backpack".
Check the site is redirected to the backpack site and the login form is displayed.
Login using the test.badgr.com user account.
Check the screen requesting your permission is displayed with the following application access permissions:
Know who you are on Badgr
Add badges into a User's Backpack
See who you are
Click button "Authorize".
Check you're redirected to the Moodle page and the following notification is displayed: "Backpack is connected".