Send Rails CSRF Token with swagger-ui requests

This commit is contained in:
richie 2016-05-18 22:53:01 -07:00
parent e10d8daa52
commit 9983261d4f
2 changed files with 16 additions and 0 deletions

View File

@ -64,6 +64,14 @@
});
addApiKeyAuthorization();
// Send Rails CSRF Token with every request
var csrfToken = new SwaggerClient.ApiKeyAuthorization(
'X-CSRF-Token',
'<%= form_authenticity_token %>',
'header'
);
swaggerUi.api.clientAuthorizations.add('csrf-token', csrfToken);
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");

View File

@ -64,6 +64,14 @@
});
addApiKeyAuthorization();
// Send Rails CSRF Token with every request
var csrfToken = new SwaggerClient.ApiKeyAuthorization(
'X-CSRF-Token',
'<%= form_authenticity_token %>',
'header'
);
swaggerUi.api.clientAuthorizations.add('csrf-token', csrfToken);
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");