.. _reaching_service_from_external_applications: Reaching a service from external applications ============================================= To be able to reach the entrypoints in your deployed services from external applications, the application has to authenticate itself. The applications require a valid authentication token which is generated by the MVI Manager. Generate an Authentication Token -------------------------------- To generate this authentication token, you will need to use the CLI. Start by making sure that you are logged in by calling the login command: >>> mvi login # doctest: +SKIP Enter MVI host: http://your-host Username: Password: When you are logged in, use the token command: >>> mvi token # doctest: +SKIP {your_token} This will generate a long-lived authentication token. This means that this token remain valid indefinitely, which can potentially pose a security risk. If you want a semi-long lived authentication, specify the number of days it should be valid by specifying an integer with your command call: >>> mvi token 10 # doctest: +SKIP {your_token} This will generate a token that is valid for 10 days. Using the Authentication Token -------------------------------------- Once you have generated the authentication token for your external application you are ready to start sending requests to the deployed services. The authentication token is used as a Bearer token and should be included in the header of the applications requests to the services as key-value pair, like this: ``"Authorization: Bearer {your_token}"`` For example, using the `requests `_ package in python:: json_data = {"data": "my_data"} response = requests.post( "services/name_version/entrypoint", json=json_data, headers={"Authorization": f"Bearer {TOKEN}"})