Giter Club home page Giter Club logo

Comments (11)

vbudilov avatar vbudilov commented on May 23, 2024

To fix this you'll need to go to the console, bring up the api, and select the POST method. Click the little pencil icon and reselect the Lambda function -- that will add the necessary permissions for it to be run. I'm looking for ways to automate this step (I might have found it). You'll need to redeploy the api once you reselect the Lambda function.

from serverless-photo-recognition.

tomhoag avatar tomhoag commented on May 23, 2024

Ok. Thanks -- not sure I would have come up with that on my own :)

I made the change in the API console as you describe and I'm still getting {"message":"Unauthorized"} when I attempt the curl statement with the pool-id and id token from the Cognito Startup webpage -- same when I run from the API Gateway Test.

However, I added to the setup script to sign-up and confirm a user in the same cognito identity pool created in the setup script (I'll share that in a pull request soon). From there I begin the authflow to fetch the id token. Using the id token and the identity pool, I'm uploading a picture and running the curl command -- authorization works just fine, the lambda function returns without errors. Here's the response received:

{"message":"Success","pictures":[]}

Getting closer -- I'm looking at the SearchPhotosHandler.kt file to see if I can track this down . . . no errors are being reported in the log file for the function.

Let me know what you think?

Also, fwiw, after I made the change to the API as you had suggested, I inadvertently forgot to redeploy the API -- and I received the success message. Perhaps the API doesnt have to be re-deployed after all??

from serverless-photo-recognition.

vbudilov avatar vbudilov commented on May 23, 2024

from serverless-photo-recognition.

tomhoag avatar tomhoag commented on May 23, 2024

The user is created with the same coginito id as the one being used in the S3 URI -- thats how it should be correct? I've confirmed via the console that the created user is in cognito pool.

I'll open a pull request so you can see how the user is being created and how I'm using it.

Thanks

from serverless-photo-recognition.

vbudilov avatar vbudilov commented on May 23, 2024

I can't replicate the isssue -- searching with the correct id works for me (as long as you follow the process of re-enabling the Lambda function, which I'm trying to automate).

from serverless-photo-recognition.

vbudilov avatar vbudilov commented on May 23, 2024

I've pushed the fix to grant api gateway the permissions to kick off the lambda function...you no longer need to reselect the function once deployed.

from serverless-photo-recognition.

tomhoag avatar tomhoag commented on May 23, 2024

fwiw, here's my experience -- running on the awslabs/master branch

Startup and login to Cognito Starter web app, copy 'Cognito id' from 'My Profile' tab

Copy an image to the S3 bucket:

 ~/Projects/AWS-SPR/setup (master)*$ aws s3 cp new-york.jpg s3://rekognition-20170226092810/usercontent/<Cognito ID copied and pasted from Cognito Starter My Profile tab>/

upload: ./new-york.jpg to s3://rekognition-20170226092810/usercontent/<snip>/new-york.jpg

Run the curl command using the ID Token from the JWT Token tab on the Cognito Starter web app

 ~/Projects/AWS-SPR/setup (master)*$ curl -X POST -H "Authorization: <ID Token copied and pasted from Cognito Starter webpage>" -H "search-key: building" -H "Cache-Control: no-cache" "https://f61jdzdb2d.execute-api.us-east-1.amazonaws.com/prod/picture/search/"

{"message":"Unauthorized"}

from serverless-photo-recognition.

vbudilov avatar vbudilov commented on May 23, 2024

Have you modified the values in the ~/aws-cognito-angular2-quickstart/src/environments/environment.ts file to reflect the newly-created cognito setup?

from serverless-photo-recognition.

vbudilov avatar vbudilov commented on May 23, 2024

Frankly, seeing how difficult it is, I'm thinking of taking some of the code you have to enable SRP and user creation automation to run through the whole scenario without needing the angular project.

from serverless-photo-recognition.

tomhoag avatar tomhoag commented on May 23, 2024

from serverless-photo-recognition.

tomhoag avatar tomhoag commented on May 23, 2024

from serverless-photo-recognition.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.