I'm trying to setup a NodeJS REST API using Google Cloud Endpoints and Google App Engine. I've cloned the offical sample project from GitHub and set up Google Cloud Endpoints using the Quickstart. Out of the box, it works fine,but I tried adding another API endpoint for a GET request at /, but the response I get after I deploy and make the request is as follows:
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"#type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
The APIs which came pre-configured works fine, but only new ones which I add aren't working.
I've configured the new endpoint properly in my NodeJS app (it works fine locally). The corresponding code I've added is:
app.get('/', function (req, res) {
res.status(200).json({ message: 'Hello, world!' });
});
I've added the following to my openapi.yaml file:
paths:
"/":
get:
description: "Returns the message \"Hello, World\""
operationId: "root"
produces:
- "application/json"
responses:
200:
description: "Hello"
schema:
$ref: "#/definitions/helloMessage"
definitions:
helloMessage:
properties:
message:
type: "string"
After running gcloud service-management deploy openapi.yaml from a terminal to deploy and configure Google Cloud Endpoints, I got the service name and the service configuration ID, which I've replaced in app.yaml, in the format specified by the QuickStart
endpoints_api_service:
name: echo-api.endpoints.[YOUR-PROJECT-ID].cloud.goog
config_id: YOUR-CONFIG-ID
(That's the format, I've replaced YOUR-PROJECT-ID and YOUR-CONFIG-ID with the right ones)
I deployed the app to Google App Engine using gcloud app deploy. I can see the app running properly, via the Google App Engine console.
Yet, the GET method on / is not being identified as a valid endpoint and I get the response as stated above.
Am I missing something? I searched a lot about this problem, but didn't come across anything useful/similar!
P.S: By added, I mean, it is the code which I've added to the corresponding GitHub cloned files
EDIT:
I changed the API endpoint from / to /hello and it works fine!! Unable to understand why the same functionality on / is not working on Google Cloud Endpoints (works locally though!)
Google Cloud Endpoints does not currently support the root path at "/". This is something that is being looked into.
Related
I'm trying to publish app from Azure DevOps to appcenter.ms
I have code building and artifacts are being generated. However, step to upload the app to appcenter always fails with the same error:
2019-01-28T14:40:34.0252515Z ##[error]"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot POST //apps//company/appname//release_uploads</pre>\n</body>\n</html>\n"
http response code: 404
I have added a service connection under Azure DevOps:
Name: api
Server URL: https://api.appcenter.ms
API Token: XXXXX
I'm using App Center Distribute step to publish.
Under build config I got app slug set correctly. What API endpoint I should use?
You can use this endpoint. I've got this issue too and stuck up for days trying to find the right answer but no reference says they change the endpoint.
Server URL: https://api.mobile.azure.com/v0.1
Although the instructions currently suggest otherwise I had success in using the org style APP SLUG setting and it fixed my issue.
{user}/{appname} is the format that worked for me.
i am using apiconnect microgateway (available on github) to connect with any existing webservice and add some policies, i figured i have to create yaml files for my existing apis and add them to api connect's directory. here is a sample yaml file they have given.
# sample_1.0.0.yaml
#
info:
version: 1.0.0
title: sample
description: sample laptop yaml
basePath: /sample
swagger: '2.0'
paths:
/echo:
get:
responses:
'200':
description: 200 OK
x-ibm-configuration:
assembly:
execute:
- javascript:
title: write a small json object
source: |
message.body = { text : 'Hello World' };
schemes:
- http
my question is how do i invoke my existing rest service in this file and define policies like authentication, hit limits etc.
here is the link of micro-gateway github
https://github.com/strongloop/microgateway
Creation of REST service in API Connect is straightforward. Follow the instructions provide by IBM
In API Connect, the configuration or the scripts what we write in Assembly section will automatically populate in the swagger file(Source section in API Designer). So we don't need to manipulate any swagger file.
To invoke the existing rest service in API COnnect. Please follow the steps which you can find in the above link.
For the creation of REST service invoking SOAP service please follow this link
Thanks
SP
Introduction
I have a hyperledger env running in secure mode by following this link https://hyperledger.github.io/composer/integrating/enabling-rest-authentication.html
and it works fine if I authenticate as specified in the document (hitting http://mydomain:3000/auth/github directly from the browser) and then access the Rest API from the http://mydomain:3000/explorer and could authorize as various participants (i.e, issuing identity and adding them to the wallet and setting one as default at a time) and could see the assets as per the .acl file.
Issue
But I started facing problems when I started integrating the Rest API's from my web application rather directly from the browser. As a first step from my web app, I called the http://mydomain:3000/auth/github to authenticate and then started calling the other APIs (transaction/list, etc.) but I do always get
Error 401: 'Authorization Required'
What i have tried
Gave my web application URL as the 'Redirect URL' in the env variable for the hyperledger. And upon successful authentication (calling http://mydomain:3000/auth/github) it successfully redirected to my webapp home page but afterwards accessing the Rest API's (from web app) again throws 'Authorization Required' error.
Environment variaable as below:
export COMPOSER_PROVIDERS='{
"github": {
"provider": "github",
"module": "passport-github",
"clientID": "CLIENT_ID",
"clientSecret": "CLIENT_SECRET",
"authPath": "/auth/github",
"callbackURL": "/auth/github/callback",
"successRedirect": "http://localhost:8080/home.html",
"failureRedirect": "/"
}
}'
Incorporated passport-github2 mechanism in my web application (i.e, registered my app with the oauth of github) and upon successful login to my web application; called the http://mydomain:3000/auth/github to authenticate to the blockchain and it did not work out as well.
I have a few questions:
Is it feasible to call the secured hyperledger Rest API's from another web application?
If Yes, how to do it? I don't find that information in the hyperledger composer documentation.
Have been trying this for a week now and have no answers. Any help would be greatly appreciated. Please let me know if anything is unclear. Thanks.
I commented about this problem on one of the existing hyperledger github issues(below link) & I want to share the solution that solved this problem for me.
https://github.com/hyperledger/composer/issues/142
Solution: as mentioned by user sstone1
Since the REST server is on a different port number to your web application, you need to specify an additional option to your HTTP client to pass the cookies to the REST server. Using the Angular HTTP client, you add the withCredentials flag, for example:
via Angular:
this.http.get('http://mydomain:3000/api/MyAsset', { withCredentials: true })
via JQuery AJAX:
$.ajax({
url: 'http://mydomain:3000/api/MyAsset',
xhrFields: {
withCredentials: true
},
headers: {
...
}
})
I am try to setup azure function with HTTP triggered and make subsequent call to azure bot framework [bot service on azure].
Following is the error i encountered while setting it up:
{
"id": "ed81eca8-d536-4534-a97d-66e6a7ca7ad2",
"requestId": "ba346904-702b-465c-b7e3-b48afe29ab33",
"statusCode": 500,
"errorCode": 0,
"messsage": "Exception while executing function: Functions.adapter -> Unable to resolve value for property 'BotAttribute.SecretSetting'."
}
Env:
Nodejs dev
Using directline-JS git repo at BotFramework-DirectLineJS
Related questions:
Azure function doesn't notify my bot (Bot Framework)
Azure Function for Bot Framework C#
The secret was defined but i was returning value in a wrong way in azure function. i.e context.done(done,data) where i was passing incoming data directly to output which did not hold secret, rather than modified version of data.
I'm trying to use the swagger node to build an API to my meteor app. I managed to build the API but could not find a good guide on how to secure it. The plan is to let our mobile app connect to the main app in the server. (For this we also need to generate device-specific keys right?)
So far we tried to setup security in swagger like this :
securityDefinitions:
oauth2:
type: oauth2
authorizationUrl: "http://swagger.io/api/oauth/dialog"
flow: "implicit"
security:
- oauth2: []
But it gave us this error:
{
"message": "unknown security handler: oauth2",
"code": "server_error",
"statusCode": 403
}
Can you please tell me why the error is coming and how to properly implement the API according to my needs? Thanks!