Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Support a HTTP GET API for issuers #897

Open
toolness opened this issue Aug 2, 2013 · 2 comments
Open

Support a HTTP GET API for issuers #897

toolness opened this issue Aug 2, 2013 · 2 comments

Comments

@toolness
Copy link
Contributor

toolness commented Aug 2, 2013

I am thinking about how to write an updated make your own badges by hand blog post for the 1.0 specification, and realized that it would be a whole lot easier to give someone a badge if you could just give them a link to pushing it to their backpack, rather than learning how to use the JS Issuer API or giving a baked PNG to a confused user.

One way to do this is by simply defining a HTTP GET endpoint that takes query string arguments specifying assertion(s) and presents the user with a standard badge acceptance UI.

Here's a very simple proof of concept, which takes all assertion URLs named by one or more assertion key-value pairs in the querystring and passes them to the non-modal issuer API. Hosting this page at a documented endpoint on the backpack would make it possible for "push to backpack" buttons to be present on pages as standard hyperlinks, rather than requiring JS. They also enable issuers to simply email/instant-message/SMS a link that directly prompts the recipient to push the badge to their backpack, without requiring any intermediaries.

This solution should work okay in the federated backpack world, too, since the GET endpoint could simply do the same discovery rigamarole that the Issuer JS API does when accessed.

<!DOCTYPE html>
<meta charset="utf-8">
<title>Easy Openbadge Issuer</title>
<p id="error" style="display: none">Error, no assertions found in
  querystring.</p>
<script src="http://backpack.openbadges.org/issuer.js"></script>
<script>
function getQueryVars() {
  var result = {};
  var query = window.location.search.substring(1);
  var vars = query.split('&');
  for (var i = 0; i < vars.length; i++) {
    var pair = vars[i].split('=');
    var name = decodeURIComponent(pair[0]);
    var value = decodeURIComponent(pair[1]);
    if (!result[name])
      result[name] = [];
    result[name].push(value);
  }
  return result;
}

var assertions = getQueryVars().assertion;

if (assertions)
  OpenBadges.issue_no_modal(assertions);
else
  document.getElementById("error").style.display = "block";
</script>
@toolness
Copy link
Contributor Author

toolness commented Aug 5, 2013

Additionally, hosting a simple form that would allow issuers to paste in an assertion URL and get back a push-to-backpack URL that they could email the recipient would be useful. This would simply take care of automatically URL-encoding the assertion URL as a querystring argument to the GET endpoint.

@stenington
Copy link
Contributor

This assumes that issuers are okay with pushing badges to the backpack with no success/failure feedback, which I think is completely true in the "make your own badges by hand" blogpost reader case. I just want to be clear that this doesn't fully replace the JS Issuer API call, since it allows the issuer to pass in a callback to get back information about the push results.

With that disclaimer, I think this is a cool idea! I think we should do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants