Transmit API keys during Shopware5 extension installation

17 views Asked by At

Is there a way upon extension installation to perform these steps from the extension?

  1. Enable API for some user or create API user
  2. Send the credentials to some external service

I need to create an automatic API connector with Shopware 5, but don't know how to do these steps automatically using plugins.

1

There are 1 answers

1
Michael T On

As you have full access to the database during the installation of a plugin, it should be no problem to create a new user or/and enable API access for it.

Also making requests should be no problem. But here you need to be aware of some things:

  • during the installation of your plugin, your own services are not yet registered in the DI container. So if you have a class sending the request, you need to instantiate it on your own.
  • make sure, that the request does not take to long, so that the install process does not run into a timeout. also catch errors which might occur, so the install process is not interrupted unexpectedly