aws-api-gateway

getting message: forbidden reply from AWS API gateway

流过昼夜 提交于 2019-11-27 13:53:24
[solved] New to AWS (and StackOverflow). I am trying to create a lambda service on AWS and have it accessed from outside via the API gateway with no authentication or restriction required. To make things easy I set the gateway for now to be a Mock. On the Get method of the API, the Authorization is set to None and the API Key is not required . When I try this, I get {"message":"Forbidden"} (same message if i connect it to the actual lambda service). Any advice on how to make it accessible? Thanks If you set 'API Key Required' option to true, please check below. you have to pass 'x-api-key'

API Gateway authentication with Cognito Federated Identities

杀马特。学长 韩版系。学妹 提交于 2019-11-27 12:33:34
问题 I want to use Cognito Federated Entity (allowing signin through Google etc), to allow access to API Gateway for a web javascript application. I managed to get the Cognito's sessionToken through signing-in with Google but I'm stuck on the API Gateway configuration for enabling the session token. Is there a good tutorial for this entire Federated Entity authentication workflow? Thanks! 回答1: Since you want to invoke APIs via authenticated Cognito identity, first Amend the auth role of the

Get detailed error messages from AWS API Gateway Request Validator

家住魔仙堡 提交于 2019-11-27 12:32:22
问题 Background I have an API Gateway created using Swagger 2.0 definitions with API Gateway extensions. I overrode the default API Gateway responses, for instance: x-amazon-apigateway-gateway-responses: BAD_REQUEST_BODY: statusCode: 400 responseTemplates: application/json: | { "error": { "code": 400, "stage": "$context.stage", "request": "$context.requestId", "message": "$context.error.message" } } The $context in the above payload comes from API Gateway variables. A sample resource/method in my

API Gateway CORS: no 'Access-Control-Allow-Origin' header

▼魔方 西西 提交于 2019-11-27 11:25:25
Although CORS has been set up through API Gateway and the Access-Control-Allow-Origin header is set, I still receive the following error when attempting to call the API from AJAX within Chrome: XMLHttpRequest cannot load http://XXXXX.execute-api.us-west-2.amazonaws.com/beta/YYYYY . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403. I attempted to GET the URL through Postman and it shows the above header is successfully passed: And from the OPTIONS reponse: How can I call my API from

How do you add CloudFront in front of API Gateway

为君一笑 提交于 2019-11-27 09:17:42
问题 API Gateway (APIG), while it uses CloudFront (CF) it does not support CDN edge caching. When I configured a CF distribution to use APIG as the custom origin, I get a permission denied error. How do I configure CF to fix this? 回答1: Until API Gateway (APIG) supports edge caching via its internal use of CloudFront (CF), I have come up with a workaround. You can indeed put CF dist in front of APIG, the trick is to force HTTPS only "Viewer Protocol Policy" AND to NOT forward the HOST header

Setting http response header from AWS lambda

与世无争的帅哥 提交于 2019-11-27 09:13:28
My API Gateway/Lamdba setup returns an http response header: Lamdba uses callback function to return the value as part of a json and the Integration Response maps it into a header (using integration.response.body) With this solution, the values are sent back both in the body and the header. How can I map headers from the Lambda response without duplicating the values in the response body? If you have Lambda proxy integration enabled, you can set the response headers as part of Lambda output and API Gateway will return them as part of the HTTP response to the client. Node.js example: callback

Get object from S3 in AWS Lambda function and send to Api Gateway

让人想犯罪 __ 提交于 2019-11-27 07:50:28
问题 I am trying to get a .jpg file from a bucket and send it back to api gateway. I believe I have the setup correct as I see stuff being logged. It grabs the file from s3 fine, and gm is the graphicsmagick library. Not sure if I am using it right though. In the lambda function I do this (alot of the code comes from the aws example): async.waterfall([ function download(next) { console.log(srcKey); console.log(srcBucket); // Download the image from S3 into a buffer. s3.getObject({ Bucket:

API Gateway CORS: no 'Access-Control-Allow-Origin' header

浪子不回头ぞ 提交于 2019-11-27 03:57:36
问题 Although CORS has been set up through API Gateway and the Access-Control-Allow-Origin header is set, I still receive the following error when attempting to call the API from AJAX within Chrome: XMLHttpRequest cannot load http://XXXXX.execute-api.us-west-2.amazonaws.com/beta/YYYYY. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403. I attempted to GET the URL through Postman and it

Signature expired: is now earlier than error : InvalidSignatureException

只谈情不闲聊 提交于 2019-11-27 01:30:30
问题 I am trying a small example with AWS API Gateway and IAM authorization. The AWS API Gateway generated the below Endpoint : https://xyz1234.execute-api.us-east-2.amazonaws.com/Users/users with POST action and no parameters. Initially I had turned off the IAM for this POST Method and I verified results using Postman it works. Then I created a new IAM User and attached AmazonAPIGatewayInvokeFullAccess Policy to the user thereby giving permission to invoke any API's. Enabled the IAM for the POST

AWS API Gateway base64Decode produces garbled binary?

ⅰ亾dé卋堺 提交于 2019-11-27 01:04:34
I'm trying to return a 1px gif from an AWS API Gateway method. Since binary data is now supported, I return an image/gif using the following 'Integration Response' mapping: $util.base64Decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") However, when I look at this in Chrome, I see the following binary being returned: Instead of: Could anyone help me understand why this is garbled and the wrong length? Or what I could do to return the correct binary? Is there some other what I could always return this 1px gif without using the base64Decode function? Many thanks in advance, this