Skip to content

Instantly share code, notes, and snippets.

@mpguerra
mpguerra / ActiveDocsXHRhijack.js
Last active August 29, 2015 13:56
An example of adding an event listener to an existing XMLHttpRequest for 3scale Active Docs in order to automatically populate access tokens for OAuth2 calls
// save the original open
var originalOpen = XMLHttpRequest.prototype.open;
function onLoad(event) {
var jsonResponse = JSON.parse(this.response);
if('access_token' in jsonResponse){
populate_access_tokens(jsonResponse.access_token)
}
}
@mpguerra
mpguerra / ADSpecOAuthClientCredentials.json
Created February 13, 2014 11:14
Example of an Active Docs JSON spec for an OAuth token endpoint for the Client Credentials Flow
{
"basePath": "http://nginx-oauth.herokuapp.com",
"apiVersion": "v1",
"apis": [
{
"path": "/oauth/token",
"operations": [
{
"httpMethod": "POST",
"summary": "Returns the Access Token to call the API",
@mpguerra
mpguerra / GoogleOAuthPlaygroundClientSideIframeLink.html
Created February 13, 2014 11:25
An Iframe link to the Google OAuth Developer Playground for a Client-Side Web Applications Flow. In a 3scale Powered Developer portal, the client_id and client_secret values are populated for a signed in users using liquid tags.
@mpguerra
mpguerra / GoogleOAuthPlaygroundServerSideIframeLink.html
Created February 13, 2014 11:26
An Iframe link to the Google OAuth Developer Playground for a Server-Side Web Applications Flow. In a 3scale Powered Developer portal, the client_id and client_secret values are populated for a signed in users using liquid tags.
@mpguerra
mpguerra / ADSpecOAuthSentimentAPI.json
Last active August 29, 2015 13:56
A sample Active Docs Spec for an OAuth enabled Sentiment API
{
"basePath": "http://sentiment-api.herokuapp.com",
"apiVersion": "v1",
"apis": [
{
"path": "/v1/words/{word}.json",
"operations": [
{
"httpMethod": "GET",
"summary": "Returns the sentiment value of a given word",
@mpguerra
mpguerra / XFrameOptions.rb
Created February 13, 2014 11:46
Setting Cross Frame Options in Ruby
config.action_dispatch.default_headers['X-Frame-Options'] = "ALLOW-FROM https://developers.google.com/oauthplayground"
@mpguerra
mpguerra / ADIncludeScript.html
Created February 13, 2014 12:01
Script to include Active Docs in the 3scale Developer Portal in a given order.
<script>
$(function(){
ThreeScale.APIDocs.init(['oauth','sentiment']);
});
</script>
@mpguerra
mpguerra / 3scaleWorkshop.md
Last active August 29, 2015 14:06
Steps and links for 3scale Workshop: Crash Course - Practical API Management
@mpguerra
mpguerra / connect_redis
Created October 28, 2014 10:32
Connecting to redistogo instance on Heroku from lua
function M.connect_redis(red)
redisurl = os.getenv("REDISTOGO_URL")
redisurl_connect = string.split(redisurl, ":")[3]
redisurl_user = string.split(redisurl_connect, "@")[1]
redisurl_host = string.split(redisurl_connect, "@")[2]
redisurl_port = tonumber(string.split(redisurl, ":")[4])
local ok, err = red:connect(redisurl_host, redisurl_port)
if not ok then
ngx.say("failed to connect: ", err)
@mpguerra
mpguerra / favicon
Created April 7, 2015 13:39
Adding a favicon to 3scale hosted developer portal
<!-- Favicon -->
<link rel="shortcut icon" href="/images/icon.ico" type="image/x-icon" />