Validating and baking open badges

894 views Asked by At

I've been trying to generate open badges for a while, but so far none of them will validate or bake using the online tools.

I've tried a variety of different combinations. Here's the one I'm using currently (sites removed due to being preproduction sites) :

On the site at http://example.org/badge/5ab0d10a6a02f :

{
    "@context":"https://w3id.org/openbadges/v1",
    "type":"Assertion",
    "id":"http://example.org/badge/5ab0d10a6a02f",
    "uid":"5ab0d10a6a02f",
    "recipient":
    {
        "type":"email",
        "identity":"[email protected]",
        "hashed":false
    },
    "issuedOn":1521564293,
    "badge":"http://example.org/badge-class.json",
    "verify":
    {
        "type":"hosted",
        "url":"http://example.org/badge-issuer.json"
    }
}

On the site at http://example.org/badge-class.json :

{
    "@context": "https://w3id.org/openbadges/v1",
    "id": "http://example.org/badge-class.json",
    "type": "BadgeClass",
    "name": "Badge",
    "description": "Description",
    "image": "http://example.org/badge.png",
    "criteria": "http://example.org/criteria",
    "issuer": "http://example.org/badge-issuer.json"
}

and at http://example.org/badge-issuer.json :

{
    "@context": "https://w3id.org/openbadges/v1",
    "id": "http://example.org/badge-issuer.json",
    "type": "Issuer",
    "name": "Name",
    "url": "http://www.example.org/",
    "telephone" : "xxxxxxxxx",
    "description" : "description",
    "image" : "http://www.example.org/logo.png",
    "email" : "[email protected]"
}

Once properly hosted on a real site, I tried to validate and bake it, but I get the following errors :

For the validators :

{
  "status": "invalid",
  "reason": "Remote assertion must match local assertion",
  "error": {
    "message": "Remote assertion must match local assertion",
    "code": "deep-equal",
    "extra": {
      "local": {
        "@context": "https://w3id.org/openbadges/v1",
        "type": "Assertion",
        "id": "http://example.org/badge/5ab0d10a6a02f",
        "uid": "5ab0d10a6a02f",
        "recipient": {
          "type": "email",
          "identity": "[email protected]",
          "hashed": false
        },
        "issuedOn": 1521564293,
        "badge": "http://example.org/badge-class.json",
        "verify": {
          "type": "hosted",
          "url": "http://example.org/badge-issuer.json"
        }
      },
      "hosted": {
        "@context": "https://w3id.org/openbadges/v1",
        "id": "http://example.org/badge-issuer.json",
        "type": "Issuer",
        "name": "Name",
        "url": "http://example.org/",
        "telephone": "xxxxxxxxx",
        "description": "description",
        "image": "http://example.org/logo.png",
        "email": "[email protected]"
      }
    }
  },
  "info": {
    "raw": {
      "input": {
        "@context": "https://w3id.org/openbadges/v1",
        "type": "Assertion",
        "id": "http://example.org/badge/5ab0d10a6a02f",
        "uid": "5ab0d10a6a02f",
        "recipient": {
          "type": "email",
          "identity": "[email protected]",
          "hashed": false
        },
        "issuedOn": 1521564293,
        "badge": "http://example.org/badge-class.json",
        "verify": {
          "type": "hosted",
          "url": "http://example.org/badge-issuer.json"
        }
      }
    },
    "parse": {
      "version": "1.1.0",
      "type": "hosted",
      "scheme": "1.1.0-hosted",
      "assertion": {
        "@context": "https://w3id.org/openbadges/v1",
        "type": "Assertion",
        "id": "http://example.org/badge/5ab0d10a6a02f",
        "uid": "5ab0d10a6a02f",
        "recipient": {
          "type": "email",
          "identity": "[email protected]",
          "hashed": false
        },
        "issuedOn": 1521564293,
        "badge": "http://example.org/badge-class.json",
        "verify": {
          "type": "hosted",
          "url": "http://example.org/badge-issuer.json"
        }
      }
    },
    "assertion": {
      "@context": "https://w3id.org/openbadges/v1",
      "type": "Assertion",
      "id": "http://example.org/badge/5ab0d10a6a02f",
      "uid": "5ab0d10a6a02f",
      "recipient": {
        "type": "email",
        "identity": "[email protected]",
        "hashed": false
      },
      "issuedOn": 1521564293,
      "badge": "http://example.org/badge-class.json",
      "verify": {
        "type": "hosted",
        "url": "http://example.org/badge-issuer.json"
      }
    },
    "guid": "38edfd9e94b1bda73a0283a02425710508e7713dc5eb78a65f93a57b67460324",
    "badge": {
      "@context": "https://w3id.org/openbadges/v1",
      "id": "http://example.org/badge-class.json",
      "type": "BadgeClass",
      "name": "Badge",
      "description": "Description",
      "image": "http://example.org/badge.png",
      "criteria": "http://example.org/criteria",
      "issuer": "http://example.org/badge-issuer.json"
    },
    "issuer": {
      "@context": "https://w3id.org/openbadges/v1",
      "id": "http://example.org/badge-issuer.json",
      "type": "Issuer",
      "name": "Name",
      "url": "http://www.example.org/",
      "telephone": "xxxxxxxxx",
      "description": "description",
      "image": "http://www.example.org/logo.png",
      "email": "[email protected]"
    },
    "objects": true,
    "recipient": true,
    "jsonld_expanded": {
      "https://w3id.org/openbadges#badge": [
        {
          "@id": "http://example.org/badge-class.json"
        }
      ],
      "@id": "http://example.org/badge/5ab0d10a6a02f",
      "https://w3id.org/openbadges#issueDate": [
        {
          "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
          "@value": 1521564293
        }
      ],
      "https://w3id.org/openbadges#recipient": [
        {
          "https://w3id.org/openbadges#hashed": [
            {
              "@type": "http://www.w3.org/2001/XMLSchema#boolean",
              "@value": false
            }
          ],
          "https://w3id.org/openbadges#identityHash": [
            {
              "@value": "[email protected]"
            }
          ],
          "@type": [
            "http://schema.org/email"
          ]
        }
      ],
      "@type": [
        "https://w3id.org/openbadges#Assertion"
      ],
      "https://w3id.org/openbadges#uid": [
        {
          "@value": "5ab0d10a6a02f"
        }
      ],
      "https://w3id.org/openbadges#verify": [
        {
          "@type": [
            "https://w3id.org/openbadges#HostedBadge"
          ],
          "http://schema.org/url": [
            {
              "@id": "http://example.org/badge-issuer.json"
            }
          ]
        }
      ]
    },
    "extensions": {},
    "extension_properties": true,
    "extension_schemas": {},
    "unrevoked": "Only required for signed verification",
    "signature": "Only required for signed verification"
  }
}

Using the baker :

Could not parse json: Unexpected token <

Using the baker API :

{
    "message":"could not get assertion: invalid JSON",
    "stack":"Error: could not get assertion: invalid JSON
        at makeError (/app/lib/analyze-assertion.js:6:26)
        at Request._callback (/app/lib/analyze-assertion.js:31:23)
        at Request.self.callback (/app/node_modules/request/request.js:187:22)
        at Request.emit (events.js:98:17)
        at Request.<anonymous> (/app/node_modules/request/request.js:1126:10)
        at Request.emit (events.js:95:17)
        at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1046:12)
        at IncomingMessage.g (events.js:180:16)
        at IncomingMessage.emit (events.js:117:20)
        at _stream_readable.js:944:16",
    "code":"parse"
}

What part of this badge is causing the issues?

1

There are 1 answers

1
user49177 On

Maybe the last eight (8) lines of the badge assertion file at http://example.org/badge/5ab0d10a6a02f should be:

{

    ...
    ... 
    "badge":"http://example.org/badge-class.json",
    "issuer":"http://example.org/badge-issuer.json",
    "verify":
    {
        "type":"hosted",
        "url":"http://example.org/badge/5ab0d10a6a02f/THIS-BADGE-ASSERTION-FILE.json"
    }
}

where THIS-BADGE-ASSERTION-FILE.json is the badge assertion JSON file and is precisely the file whose contents we are modifying. That is to say, the "verify" URL should point to the badge assertion JSON file (that resides within the folder http://example.org/badge/5ab0d10a6a02f/) and not to the badge-issuer.json file which is the badge issuer JSON file.