aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Create user using admin queries #8223

Closed CLMichel closed 3 years ago

CLMichel commented 3 years ago

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

GraphQL API

Amplify Categories

auth, storage, function, api

Environment information

System: OS: Windows 10 10.0.19041 CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx Memory: 866.71 MB / 6.94 GB Binaries: Node: 12.16.2 - C:\Program Files\nodejs\node.EXE npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 90.0.4430.93 Edge: Spartan (44.19041.906.0), Chromium (90.0.818.51) Internet Explorer: 11.0.19041.1 npmPackages: @aws-amplify/ui-components: ^1.2.0 => 1.2.0 @bootstrap-vue/alert: 1.0.0 @bootstrap-vue/aspect: 1.0.0 @bootstrap-vue/avatar: 1.0.0 @bootstrap-vue/badge: 1.0.0 @bootstrap-vue/breadcrumb: 1.0.0 @bootstrap-vue/button: 1.0.0 @bootstrap-vue/button-group: 1.0.0 @bootstrap-vue/button-toolbar: 1.0.0 @bootstrap-vue/calendar: 1.0.0 @bootstrap-vue/card: 1.0.0 @bootstrap-vue/carousel: 1.0.0 @bootstrap-vue/collapse: 1.0.0 @bootstrap-vue/dropdown: 1.0.0 @bootstrap-vue/embed: 1.0.0 @bootstrap-vue/form: 1.0.0 @bootstrap-vue/form-btn-label-control: 1.0.0 @bootstrap-vue/form-checkbox: 1.0.0 @bootstrap-vue/form-datepicker: 1.0.0 @bootstrap-vue/form-file: 1.0.0 @bootstrap-vue/form-group: 1.0.0 @bootstrap-vue/form-input: 1.1.0 @bootstrap-vue/form-radio: 1.0.0 @bootstrap-vue/form-rating: 1.0.0 @bootstrap-vue/form-select: 1.0.0 @bootstrap-vue/form-spinbutton: 1.0.0 @bootstrap-vue/form-tags: 1.0.0 @bootstrap-vue/form-textarea: 1.0.0 @bootstrap-vue/form-timepicker: 1.0.0 @bootstrap-vue/icons: 1.0.0 @bootstrap-vue/image: 1.0.0 @bootstrap-vue/input-group: 1.0.0 @bootstrap-vue/jumbotron: 1.0.0 @bootstrap-vue/layout: 1.0.0 @bootstrap-vue/link: 1.0.0 @bootstrap-vue/list-group: 1.0.0 @bootstrap-vue/media: 1.0.0 @bootstrap-vue/modal: 1.0.0 @bootstrap-vue/nav: 1.0.0 @bootstrap-vue/navbar: 1.0.0 @bootstrap-vue/overlay: 1.0.0 @bootstrap-vue/pagination: 1.0.0 @bootstrap-vue/pagination-nav: 1.0.0 @bootstrap-vue/popover: 0.0.0 (1.0.0) @bootstrap-vue/progress: 1.0.0 @bootstrap-vue/scrollspy: 0.0.0 @bootstrap-vue/sidebar: 1.0.0 @bootstrap-vue/skeleton: 1.0.0 @bootstrap-vue/spinner: 1.0.0 @bootstrap-vue/table: 1.0.0 @bootstrap-vue/tabs: 1.0.0 @bootstrap-vue/time: 1.0.0 @bootstrap-vue/toast: 1.0.0 @bootstrap-vue/tooltip: 0.0.0 (1.0.0) @bootstrap-vue/transition: 1.0.0 @bootstrap-vue/transporter: 1.0.0 @bootstrap-vue/v-b-hover: 1.0.0 @bootstrap-vue/v-b-toggle: 1.0.0 @bootstrap-vue/v-b-visible: 0.0.0 @nuxtjs/axios: ^5.13.1 => 5.13.1 @nuxtjs/eslint-config: ^6.0.0 => 6.0.0 @nuxtjs/eslint-module: ^3.0.2 => 3.0.2 @nuxtjs/vuetify: ^1.11.3 => 1.11.3 amplify-ui-components-loader: undefined () aws-amplify: ^3.3.27 => 3.3.27 aws-amplify-vue: ^2.1.5 => 2.1.5 babel-eslint: ^10.1.0 => 10.1.0 bootstrap: ^4.6.0 => 4.6.0 bootstrap-vue: ^2.21.2 => 2.21.2 core-js: ^3.9.1 => 3.10.1 (2.6.12) eslint: ^7.22.0 => 7.24.0 eslint-plugin-nuxt: ^2.0.0 => 2.0.0 eslint-plugin-vue: ^7.7.0 => 7.9.0 nuxt: ^2.15.3 => 2.15.4 nuxt-vuex-localstorage: ^1.3.0 => 1.3.0 npmGlobalPackages: @angular/cli: 10.1.7 @aws-amplify/cli: 4.50.0 @vue/cli: 4.5.8 create-react-app: 3.4.1 eslint: 7.24.0 expo-cli: 3.21.3 gulp-cli: 2.3.0 nodemon: 2.0.5

Describe the bug

0

I'm trying to create user using admin queries in Amplify.

I have this code to create a new user :

async createUser(userEmail) {
    let apiName = "AdminQueries";
    let path = "/createUser";
    let data = {
      body: {
        username: userEmail,
      },
      headers: {
        "Content-Type": "application/json",
        Authorization: `${(await Auth.currentSession())
          .getAccessToken()
          .getJwtToken()}`,
      },
    };
    return await API.post(apiName, path, data)
  },

And when I use this function the server respond with an error 404.

Expected behavior

When I use this function it should create a new user in cognito.

Reproduction steps

Run the above code and send to the function an email.

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

chrisbonifacio commented 3 years ago

Hi @CLMichel 👋 I apologize for the delay. Are you still experiencing this issue? If so, could you please take a look at the documentation for Admin Queries?

https://docs.amplify.aws/cli/auth/admin#admin-queries-api

There doesn't seem to be a /createUser route, which would explain the 404, but there is a /addUserToGroup route. Maybe that's the one you want? If not, I think the only way to create a new user would be through Auth.signUp.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

chrisbonifacio commented 3 years ago

Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.