验证和烘焙打开的徽章

时间:2018-03-30 09:50:01

标签: json openbadge

我一直试图生成开放徽章一段时间,但到目前为止,他们都不会使用在线工具进行验证或烘焙。

我尝试了各种不同的组合。这是我目前使用的那个(由于是预生产网站而删除的网站):

http://example.org/badge/5ab0d10a6a02f的网站上

/// Modulation Control
case modulationWheel = 1
/// Breath Control (in MIDI Saxophones for example)
case breathControl = 2
/// Foot Control
case footControl = 4
/// Portamento effect
case portamento = 5
/// Data Entry
case dataEntry = 6
/// Volume (Overall)
case mainVolume = 7
/// Balance
case balance = 8
/// Stereo Panning
case pan = 10
/// Expression Pedal
case expression = 11

http://example.org/badge-class.json的网站上

midi.sendEvent(AKMIDIEvent(controllerChange: 7, value: MIDIByte(volume), channel: MIDIChannel(0)))

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

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

在真实网站上正确托管后,我尝试验证并烘焙它,但我收到以下错误:

对于validators

{
    "@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"
}

使用baker

{
    "@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@example.org"
}

使用baker API

{
  "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@example.org",
          "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@example.org"
      }
    }
  },
  "info": {
    "raw": {
      "input": {
        "@context": "https://w3id.org/openbadges/v1",
        "type": "Assertion",
        "id": "http://example.org/badge/5ab0d10a6a02f",
        "uid": "5ab0d10a6a02f",
        "recipient": {
          "type": "email",
          "identity": "email@example.org",
          "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@example.org",
          "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@example.org",
        "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@example.org"
    },
    "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@example.org"
            }
          ],
          "@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"
  }
}

此徽章的哪一部分导致了这些问题?

1 个答案:

答案 0 :(得分:0)

也许http://example.org/badge/5ab0d10a6a02f处的徽章声明文件的最后八(8)行应该是:

{

    ...
    ... 
    "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"
    }
}

其中THIS-BADGE-ASSERTION-FILE.json是徽章声明JSON文件,也正是我们要修改其内容的文件。也就是说,“验证” URL应该指向徽章声明JSON文件(位于文件夹http://example.org/badge/5ab0d10a6a02f/中),而不指向作为徽章颁发者{ {1}}文件。