API calls for third party HTTP restful API from dfinity canisters - rust

I m trying to find a way to make Restful API calls from Canisters (for SSO with OAuth) with Motoko but never found any library that.
Is there any HTTP client library available for Motoko?
Is not is there a way to import any HTTP client library from another language such as Rust, C++, ... with Motoko?
If not is it possible tto do it with Rust by importing an HTTP client library for rust?
If it's not possible to doing from the canisters, if it there any services in the Internet-Computer or Dfinity (ou any web3 solutions) to perform tasks like serverless functions like major cloud solutions to perform this simple task?
Thanks

As demonstrated during the first public Global R&D, an example of canister HTTP request Rust sample dApp retrieving exchange rate between ICP and USDC using the Coinbase API has been published to dfinity/examples GitHub repository.
This example is lacking a Motoko equivalent but fundamentally there isn't any obstacle to do it as the canister HTTP request is relying on inter-canister call to the management canister.
Otherwise you can deploy a Rust canister making the canister HTTP request and interact with this canister in Motoko to keep your codebase in Motoko while not having to translate the canister HTTP request in Motoko (but IMO it should be quite easy to translate to Motoko as there isn't much code and the dependencies are Motoko friendly).
For more documentation, you may find out candid specification for http_request management canister endpoint here and the technical specification here.

Seems this feature will be released in a near future (August 2022) following the Dfinity Forum:
https://forum.dfinity.org/t/enable-canisters-to-make-http-s-requests/9670/96

Related

Client side javascript SDK for Docusign REST API

I have been looking for a way to make API calls to the Docusign REST API using strictly client-side javascript (no Node). I haven't been able to find a single example of how to do this which leads me to believe it's not possible for some reason.
Furthermore I haven't seen an SDK for client side javascript calls. Only the following are available: C#, Java, Objective C, Node, PHP
https://www.docusign.com/developer-center/api-overview#sdk-docusign
So my question is this, is it possible to make purely client side calls to the Docusign API?
Not fully from a client side, due to CORS restrictions for security purposes.

Sending HTTP request from reactjs/flux to nodejs and sending back HTTP response

Are there are any good simple examples of sending http requests with data from reactjs/flux to nodejs and from the nodejs server sending back an HTTP response with data? I was able to do this in AngularJS with Nodejs since it had a $http service but am confused on how to do this with reactjs. Any help is appreciated.
ReactJS does not come with a http service like you have in AngularJS. That is the way they keep their Library lean.
For making http requests, you can use:
JQuery (Most advised, as its the most used library on the frontend and probably your project or theme is already using it, so no need to include any new library).
Axios, really nice implementation of the Promise API and Client side support for protecting against XSRF (plus supports IE8)
Fetch, built by Github so support is pretty good
Superagent, small, easy to use and easily extensible via plugins

WSDL off ServiceStack REST API

I know this at least IMO is a stupid request. Because WSDL is old hat and sucks compared to just doing a RESTful API. But I have a corporate "mandate" where we want to do a REST API but then corporate wants a WSDL still. I know..it makes no sense and apparently we can't push back and say NO and tell them to just use our future REST API.
So can you generate a WSDL if I were to start creating a REST API with ServiceStack? Meaning I add uri attributes and such? So that I can "make them happy"?
I prefer not to use WCF, it's a nightmare with a ton of attributes and configuration to try and hack a RPC style web service to try and be RESTful. Obviously that doesn't work out too well.
SOAP along with REST is supported and you can have REST API along with soap wsdl. There are some recommendations posted in servicestack wiki that you can review and get started! You just need to implement the restful service and soap, json, xml etc are automatically supported.

How would RESTful API for Parse work for HTML application?

Parse is a Backend-as-Service platform that offers RESTful API for data storage and query. It seems very appealing for front-end or mobile developer and allows them to focus on business logic without worry about those troublesome back-end technologies.
The RESTful endpoint looks something like this:
https://api.parse.com/1/classes/GameScore
If I want to use this on my site, say awesomehtmlsite.com, wouldn't the request be blocked by cross domain restrictions? Same would hold true for the Javascript API.
Can someone explain to me how I can utilize the RESTful API or the Javascript API?
Responses to calls to the Parse javascript API include the following header:
Access-Control-Allow-Origin:*
This allows it to be used cross-domain. You should just be able to follow the JavaScript guide/API that Parse provides, without worrying about cross-domain issues.

Using Google AppEngine Urlfetch instead of urllib2

What is the difference between Google's urlfetch over the python lib urllib2 ?
When I came upon Google's urlfetch I thought maybe there were security reasons. Perhaps Google is safer in terms of malicous urls or something?
Is there any reason why I should choose Google's urlfetch over urllib2?
Note that in GAE urllib, urllib2 and httplib are just wrappers around UrlFetch (See Fetching urls in Python).
One difference of the urlfetch module is that provides you with an interface for making Asynchronous requests.
I don't work for Google, so this is just a guess from various GAE posts I've read. App Engine instances don't face the internet directly, but are buried behind layers of Google infrastructure. When a browser makes an HTTP request, it doesn't go straight to your instance, but rather it hits a Google edge server which eventually routes the request to a GAE instance.
Likewise when making an HTTP request out, your instance doesn't just open a socket (which urllib2 will normally do), but rather it sends the HTTP request to some other Google edge server which goes makes that HTTP request. Using urllib2 on GAE will use a GAE specific version which runs on top of urlfetch.
There is no problem to use standard libraries in App Engine. Url Fetch Api is just a service to make HTTP request more "easily" than urlib2. It is more understable for a novice in Python and you can easily use a non blocking request for example.
I suggest you to read some complementary information here: https://developers.google.com/appengine/docs/python/urlfetch/overview
If google found some security problem on a Python standard libraries. I guess It will send a fix ;)
The difference is : urlfetch only has a functional interface and urllib and httplib have a OO interface. An OO interface can be very usefull. I have seen a good example in the oauth2 client lib, where the request instance is passed to the client lib to check if the token is valid and authorized.

Resources