#How to add existing REST API to Amplify?

18 messages · Page 1 of 1 (latest)

mental latch
#

I'm trying to use an existing (and working) API Gateway REST API with Amplify. From what I read, all that is needed is adding an API directive to Amplify.configure(). So, I tried the following in my _app.js file:

import awsconfig from '../src/aws-exports';
Amplify.configure(
    {
        ...awsconfig, ssr: true,
        API: {
            endpoints: [
                {
                    name: "DanzanRyuAPI",
                    endpoint: "https://ufr7cpns3i.execute-api.us-west-1.amazonaws.com/test",
                }
            ]
        }
    }
);

Unfortunately, I get the following error: error Error: API DanzanRyuAPI does not exist

What am I doing wrong?
TIA,
-T

#

How to add existing REST API to Amplify?

#

@josef Thoughts?

sweet ibex
#

Did you figue it out? I'm having a similar issue and have nowhere to start

mental latch
#

@sweet ibex I ended up doing something like this:

Amplify.configure(
    {
        API: {
            endpoints: [
                {
                    name: "KilohanaInstructorsAPI",
                    endpoint: "https://xxxxxxxx.execute-api.us-west-1.amazonaws.com/prod1",
                    region: "us-west-1",
                    custom_header: async () => {
                        return {Authorization: 'token'};
                    }
                }
            ]
        },
        ...awsconfig, ssr: true,
    }
);
#

The above works

sweet ibex
#

I want to do it without CLI

#

but

mental latch
#

This is without the cli. It's a rest API. I have a lambda function that lives on AWS that interfaces with a cognito.

sweet ibex
#
const amplifyconfig = '''{
  "auth": {
    "plugins": {
      "awsCognitoAuthPlugin": {
        "CognitoUserPool": {
          "Default": {
            "PoolId": "xxxx",
            "AppClientId": "xxx",
            "Region": "xx-xx-1"
          }
        },
        "Auth": {
          "Default": {
            "OAuth": {
              "WebDomain": "xx.xx.com",
              "AppClientId": "xx",
              "SignInRedirectURI": "authRedirectPath",
              "SignOutRedirectURI": "authSignOutPath",
              "Scopes": [
                "email",
                "openid",
                "profile",
                "aws.cognito.signin.user.admin"
              ]
            }
          }
        }
      }
    }
  }
}''';```
#

This is mine right now

#

But, I do not know what to put on SignInRedirectURI

#

Like, I want the user to sign in using Google that then is authenticated by my cognito thing on aws

mental latch
#

Sorry, I'm confused about what you're trying to do. I don't necessarily disagree with what your definitions are, I just don't understand what you're trying to accomplish.

sweet ibex
#

I'm trying to sign in using google, the dialog box pops up and a link is opened, but I can't really sign in, it gives me an error

mental latch
#

ah, ok. Sorry, I'm not sure how to help with that.

sharp needle
#

Hey, were you guys able to add an existing API? If so how did you push this to the Amplify backend?