-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic HTTP Authentication Example? #3
Comments
Cool this has been resolved. More cool stuff coming soon. For anyone looking to get started with any of the authenticated API requests, here's some tips.
|
@MCDELTAT hey... sorry, just saw this now. Glad you figured it out. Look forward to seeing your examples :) |
Super helpful, @MCDELTAT. What might a similar snippet look like that both authenticates and posts a new show record on a given channel? |
@nwatv I'll try and write one out for you tomorrow. Be aware though, this is obviously not an optimal or secure solution, as it would expose your Cablecast credentials to the public. I was just highlighting the code above so that if desired, people could play around with the API and make some cool stuff. We are currently developing our website with a MERN stack so I can hide these credentials away on the server side. One of the cooler features I'm about to release is the ability for our Public Access members to remotely upload their shows, scan the file for viruses, and then transfer it to our server for playback, with a brand new show record to match it. |
@MCDELTAT That'd be incredible. Masking the credentials is easy enough, but the framework is hugely appreciated. The member uploads system sounds great--do you have a central space to follow your public access-related projects? |
I'm currently working on adding some cool Cablecast integrations features into our new website and I'm having trouble understanding how to send the Authentication header with my request. I'd appreciate it if I can just get a super quick example of sending that header and then carrying out an innocent action like perhaps "POST v1/digitalfiles/{id}/reindex" since any valid file will just get reindexed and be valid again.
Once that's out of the way, I'll be sure to merge my code here. We have some cool examples in the works. Thanks.
EDIT: I made a few new attempts using modified stuff from SO (let's not lie here) and reading the jQuery documentation. The code below (with username, pass, and IP obviously changed to correct values) gives me the following error:
"request header field is not allowed by access-control-allow-headers"
Ideas?
``var username = "plaintextUser";
var password = "plaintextPass";
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = btoa(tok);
return "Basic " + hash;
}
$.ajax
({
method: "POST", //use for jquery above 1.9.0 else type: 'POST'
url: "http://xxx.xxx.xxx.xxx/cablecastapi/v1/digitalfiles/867/reindex",
dataType: 'json',
async: false,
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', make_base_auth(username, password));
},
success: function (){
alert('The file is being reindexed!');
}
});
console.log("Testing connection.");
The text was updated successfully, but these errors were encountered: