0

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

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

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@example.org",
        "hashed":false
    },
    "issuedOn":1521564293,
    "badge":"http://example.org/badge-class.json",
    "verify":
    {
        "type":"hosted",
        "url":"http://example.org/badge-issuer.json"
    }
}

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

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

正确托管在真实站点上后,我尝试对其进行验证和烘焙,但出现以下错误:

对于验证器

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

使用面包师

Could not parse json: Unexpected token <

使用面包师 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"
}

该徽章的哪一部分导致了问题?

4

1 回答 1

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/中),而不是指向badge-issuer.json徽章颁发者文件的JSON文件。

于 2019-01-31T05:12:00.557 回答