Importers.Remote - Support Authentication #184

Open
gregberns opened this Issue Oct 31, 2012 · 1 comment

Comments

Projects
None yet
2 participants

Currently Dataset can use the Remote Importer to pull data from an external data source. It does not appear that the Remote importer supports an authenticated URL, though.

Without support for authentication, I it seems like developers will have to re-write the Remote Importer and support that code independent of the project.

Since the Remote importer is part of the project, I would think it would be beneficial to the project to support authenticated data sources through it.

Thx for considering
Greg

This request is similar to the following issue, but I would argue it is more generic and valuable to all.
#76

I think I got this working with a very small change. In "Dataset.Xhr" of the Remote Importer, there are two lines of AJAX code, 'settings.ajax.open()' and 'settings.ajax.send()'. If you call 'settings.ajax.setRequestHeader()', you can set the Auth header.

So to get this implemented, you could use the code below. Then when the developer wants to pass in the auth, they can by supplying 'auth' as a parameter when extending the Remote object.

settings.ajax.open(settings.type, settings.url, settings.async);
if (settings.auth) {
settings.ajax.setRequestHeader('Authorization', settings.auth);
}
settings.ajax.send(settings.data || null);

I don't know if this is 'best practice' or would be considered good coding(I'm a bit of a nube), but I think it works.

iros was assigned Nov 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment