Hi I am quite new to java script and i am looking a working example to call back ends using java script channel API . I do not have any idea about channel API . Can anyone provide me a working example
If you're asking how to get a message from the backend to a javascript client: you can't send messages from a backend server to a channel created on a frontend server. This is because the app version number is included in the channel token, and backends have a different app version than frontends. You could, however, implement a servlet in your backend that calls createChannel and returns it to your frontend for inclusion in javascript that your frontend renders.
If you're trying to send a message to a backend from your javascript code, you won't be able to use XmlHttpRequest directly because of the same-origin policy (this assumes your clients are rendered from a non-backend instance). You could get around this using JSONP, or by routing XHR requests from your frontend to your backend in a frontend servlet.
Did you see the docs? Java / Python
Related
I'm currently making a webpage that will show the status of the endpoints of my api. I have little background in nodejs. The webpage is simply a table that has the endpoint name and shows red/green/yellow box. I had some problems using ajax because of the cross-origin header. I was using the XMLHttpRequest.
Now I will try to do is creating a nodejs server that can fetch this information but I'm having some problems understanding if I need to use express in order to create an app or can I use the 'request' library.
Im kinda confused on how to connect my frontend with a nodejs backend.
Typically you connect your front end to a nodejs background the way you connect most client apps to an api, through an Ajax request (XMLHTTPRequest). If you want real-realtime then you would use sockets so you can push updates to the page. If slightly realtime is ok, then you can poll from the client every 5-10 seconds.
You mentioned CORS. If you are trying to access an API that doesn't set cross-origin header, then you proxy requests through your express server since CORS is a browser policy.
Without more information I can't be more specific.
I've got a big problem to correctly implement (couple) oauth2 within Django project with Javascript (reactjs) frontend.
As a backend we are using Django server - this server offers some APIs to store or retrieve data from SQL database.
I am following this guide: Django OAuth Toolkit Documentation and using password based grant type (there are three others at disposal).
What is working for me is that I can access server's API calls via command line using curl. That is, I know how to acquire token using URL like example.com/o/token and then I can call some of my APIs with granted token within header as "Authorization: Bearer acquired_token".
I am new to OAuth within little knowledge on this topic so far.
For information:
all the stuff is running within Docker container. Reactjs is build using webpack. Within first request (clean browser cache - no javascript/reactjs available) django server is contacted and it servers index.html page with all the javascript stuff. Then Reactjs is present in browser and runs the Reactjs frontend which makes calls to APIs to get data from database and show them within some tables, etc.
My problem and question is what needs to be done on frontend side (javascript - reactjs) and in what order.
Yet I am also not sure, what to use actually within OAuth - password or authorization token and also what yet needs to be done on backend side.
Last note: I know there are lot of resources on this topic on the world wide web. However, somehow I could not find clear procedure how to deploy it.
Any good piece of advice on this perhaps with pointers to some resources is welcome and appreciated.
I'm quite new to web applications and have decided to create a single page web app hosted on Heroku.
My understanding of this web app is as follows:
Client side (AngularJs) has input text box, once button press it requests server side endpoint
Server (NodeJs) uses data from client to call external API (e.g imgur API) and returns json
Server processes json and responds to client with information
Client uses server response to render user interface
Main Concerns
Best practices for external API calling: Should I have an API wrapper class that allows me to call custom methods that return specific external api calls?
How should I handle http error responses?: I understand that NodeJs is async by nature and all http calls are done async as well. If there are multiple responses, error or success, how do I go about handling them all without doing a custom set of ".error()" and ."success()" methods for each call?
Furthermore
I cannot seem to find a good reference material for a simple NodeJs back end like the one I described. Please direct me if there are any.
I recommend looking at this Scotch.io article for creating a Single Page MEAN Application:
Setting Up a Single Page MEAN Application Starter Kit
I have a nifty AngularJS application that uses a JBoss (WildFly 8) RESTful API to retrieve data. To integrate it into my corporate environment, it requires Kerberos authentication. I've see miles of documents and examples, and even some customized advice from an internal Java developer. My problem, at this time, is where in the architecture can/should the Kerberization take place?
Is it upon entry to the AngularJS app? As in do not allow unless the ticket is authorized?
Or do I challenge each API call? If this is the case, then how would I pass along the client Kerberos ticket information to the API call?
If my question sounds disjointed, or naive, it is. This is my first interaction with Kerberos.
Help appreciated, thanks.
I ran into the same problem / challenge with a PHP REST API on an Apache webserver with Kerberos auth.
Since Angular is pure client side every request is made as 'you' in Kerberos terms so you don't have to send the ticket. Your browser already sends the ticket when the request is made.
I created a login (or check logged-in) API endpoint in my PHP API which is called before every locationChange in Angular. If the login action returns false or nothing at all you are redirected to a access_denied.html page residing next to index.html (Angular).
The login action REST endpoint returns some userdata and permissions so you can do authorization.
In my case (also still searching) I also have some authorization on the API level.
Since my implementation involves a corporate webapplication I will add some code examples tomorrow ;)
with a jboss api, it means with java code not with php and httpd in front, you can do it directly in jboss an example :
https://github.com/dstraub/spnego-wildfly
we ar doing exactly this and it works a charm, there is some example with tomcat, jboss and wildfly (different)... tell me if you have any problem... with front Angular JS and API java
We'd like a simple API explorer written in Javascript to test our custom REST API that we are building for an iOS app. The API sends GET and POST requests (POST requests are sent with multipart/formdata encoding) and returns JSON.
I've found:
apigee.com explorer (this is a hosted solution and quite complex to configure)
mashery iodocs which is written in Node.JS
Django API playground - which requires server-side stuff
As far as I can see this should be a purely client-side application - just form the requests, receive responses and display. Surely someone must have written something like this already?!
Sounds like you're looking for Swagger UI. Demo: http://petstore.swagger.io