GSA / auctions_api

An API for GSA auctions data.
http://gsa.github.io/auctions_api
The Unlicense
3 stars 8 forks source link

integrate the api key signup into your microsite #12

Closed gbinal closed 9 years ago

gbinal commented 10 years ago

@gui - can you share instructions or file a pull request for how we could integrate the api key signup into a page on gsa.github.io/auctions_api?

I'd then recommend adding a sidebar nav item for the api key signup page. That way developers don't leave your microsite when they get a key

GUI commented 10 years ago

This embeddable signup form is a feature that's implemented, but we might still need to tweak based on your requirements. If this ends up working for you, then I can writeup more formal documentation around this feature for other participating agencies.

Here's a demonstration of how the signup flow currently works on another site: http://jsfiddle.net/nickblah/Vvk7P/4/

Basically, it embeds the exact signup form and flow you see on api.data.gov into your website. It should inherit your page's default styles, but you can customize the look and feel as you see fit. If you want functional changes (like hiding/showing certain fields during signup, or different text or different links on the confirmation page), then let us know, and we'll see what we can do to make it customizable.

To use it on your own page, you'll want to embed that snippet of code from the jsfiddle on your own page. However, you'll want to change the apiKey variable in the source to this one I created just for the Auctions API: 0aYAx2eY37dkfjqsrrZ53SSCkY1yY2kRYGvY27rv So I think this should be the snippet you'd use in its entirety:

<div id="apidatagov_signup">Loading signup form...</div>
<script type="text/javascript">
  /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  var apiUmbrellaSignupOptions = {
    registrationSource: 'web',
    apiKey: '0aYAx2eY37dkfjqsrrZ53SSCkY1yY2kRYGvY27rv'
  };

  /* * * DON'T EDIT BELOW THIS LINE * * */
  (function() {
    var apiUmbrella = document.createElement('script'); apiUmbrella.type = 'text/javascript'; apiUmbrella.async = true;
    apiUmbrella.src = 'https://api.data.gov/static/javascripts/signup_embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(apiUmbrella);
  })();
</script>
<noscript>Please enable JavaScript to signup for an <a href="http://api.data.gov/">api.data.gov</a> API key.</noscript>

Let us know if you have any questions or run into any issues with embedding this. I'd also be happy to submit a pull request with this update, but I thought you might want to first play around with it to get a sense of how it works or if there's any changes you'd like to see.

gbinal commented 10 years ago

That looks great. @kishoregh - mind if I try setting this up for you and you can see if you like it?

kishoregh commented 10 years ago

Sure. If you don't mind can I stop by to see how you do a pull request?

Thank you,

Kishore Nedurumalli Asset&Transportation Div Office of the GSA CIO Phone: 443-722-2743

On Wed, Oct 1, 2014 at 12:36 PM, Gray Brooks notifications@github.com wrote:

That looks great. @kishoregh https://github.com/kishoregh - mind if I try setting this up for you and you can see if you like it?

— Reply to this email directly or view it on GitHub https://github.com/GSA/auctions_api/issues/12#issuecomment-57495396.

gbinal commented 10 years ago

Sure.

kishoregh commented 10 years ago

Will stop by after my 2 - 3 pm meeting. Is that time works for you? If not please suggest another time.

Thank you,

Kishore Nedurumalli Asset&Transportation Div Office of the GSA CIO Phone: 443-722-2743

On Wed, Oct 1, 2014 at 1:12 PM, Gray Brooks notifications@github.com wrote:

Sure.

— Reply to this email directly or view it on GitHub https://github.com/GSA/auctions_api/issues/12#issuecomment-57501037.

gbinal commented 10 years ago

@GUI - Embedding the code seemed to work fine but we're hitting an issue when clicking 'Signup' (screenshot below). Can you check it out?

http://gsa.github.io/auctions_api/key https://github.com/GSA/auctions_api/blob/gh-pages/key.md

screen shot 2014-10-01 at 3 33 38 pm

GUI commented 10 years ago

Oops, sorry about that! I had mis-configured the api key I had given you for this site. It should be working now. Note that this api key will only work if you submit it from the gsa.github.io webpage, though, so it won't work if you're doing local development. We would also need to adjust it if you ever started using a different domain to host your documentation. (If this is a hindrance at all, let me know and we can adjust, this is mainly just done to ensure we know who's embedding our signup form and where).

I also fixed the styling of that error box that was popping up. There was actually an error message in there, but it was being obscured by the header. I tweaked the styling on our end so the box rises above the rest of the content on this page (but hopefully you won't be seeing that again):

screen shot 2014-10-01 at 7 08 10 pm

GUI commented 10 years ago

Related to this, I just submitted pull request #19 with one minor tweak to the embed code that I had forgotten about. It'll just help with the analytics, so if you could pull that in, that would be great. Thanks!

gbinal commented 10 years ago

@GUI - Thanks for your help. It appears to be integrated well, though there's two changes that will make for a smoother integration.

For these embeds, the "What's Next/Explore our.../Need More help..." section should be taken out and the bottom most contact us link should go to https://api.data.gov/contact/ instead. This should be the case for all of the default embed codes that we offer to agencies to incorporate.

GUI commented 10 years ago

Should be done. For the embedded signup form, there's no longer that extra "what's next" text. The contact link has also been adjusted. I also submitted a new pull request to adjust the example URL you get with your API key in it to use the auctions API instead of the random NREL API that was used in the docs previously: https://github.com/GSA/auctions_api/pull/20

If you did want to embed any extra content below the api key details (the place where "what's next" used to be), there is an option so you can add extra content there tailored to your use-case. I'll document these various options more formally, but the short of it is, you can pass any HTML into another signupConfirmationMessage option in your snippet that will show up there. Or you can certainly leave it blank.

GUI commented 10 years ago

Oh, although I did just realize that the e-mail confirmation each user gets after signing up still has a hard-coded "What's Next" text in it. Fixing those e-mails is a little more involved, but certainly doable. But before I dive into that, any specific requests surrounding how we should handle the e-mail content? Would you just like the ability to strip that "What's Next" content, or should we perhaps do a bit more to explain that this key can be used for various APIs (since the subject is "Your api.data.gov API key" and the user may not have ever visited api.data.gov if they're signing up via this embedded form on an agency's site).

gbinal commented 10 years ago

Stripping for now is fine.

kishoregh commented 10 years ago

I can request multiple API keys with single email address. I think if the API key is given for a particular email address, the system simply should give the same API key to the user instead of giving a new key.

gbinal commented 9 years ago

@kishoregh - totally fair point though the api key service is setup currently to maximize simplicity and ease of use, in part by having the keys be very lightweight and throw-away. Feel free to repost the idea as an issue in the api.data.gov project repo, but I'm going to go ahead and close this issue since the original intent is fulfilled.