Hi @tris_w ,
In 2019 the FME Token Service has been deprecated. However this service has remained in the product for backwards compatibility and will continue to work for creating new tokens, however, will not be able to update or retrieve existing Tokens, but you should still be able to use this for your needs. Alternatively, you can also make use of the REST API tokens endpoint.
The key thing to note is that this token service requires you to input your username and password, however in FME 2020 onwards by default you are forced to update your password or first login, and so cannot make use of your user until this is done. Therefore as part of your silent install script, you should set the installation property FIRSTLOGINCHANGEPASSWORD=false so that you are not prompted to update the password and can then retrieve a token.
After this is complete you may wish to use the REST API PUT /security/accounts/< account >/password
to update this password to something other than 'admin'.
Thanks Holly, I'd like to use the rest API since the tokens service has been deprecated. In the API documentation it say "A token is required to access the REST API. This must be provided with every request...". So with a fresh install that has no tokens, how do you use the API to create a token? Is there a way to bypass the token and log in using default user/password: admin/admin?
Make a call to this rest end point with Basic Authentication of the required user account
https://docs.safe.com/fme/html/FME_REST/apidoc/v3/index.html#!/tokens/createForm_post_1
This was easier than I was making it, thanks! This code worked in python:
import requests
requestUrl = r'http://xxx:8080/fmerest/v3/tokens'
requestData = {"user": "admin",
"expirationTimeout":3600,
"name":"apiTestToken",
"restricted":"false",
"enabled":"true",
"update":"true"}
req = requests.post(requestUrl,data=requestData,auth=('admin','admin'))
print(req.text)
Thanks @hkingsbury , that's right. While we recommend using a token for security reasons, you can use Basic Authentication with the Rest API.
If you were to use Postman or the HTTPCaller in FME there is a section for Basic Auth, so thanks @tris_w for sharing how it needs to look in Python.
Basic Auth can also be set up using a Header:
- combine the username and password with a colon e.g. admin:admin
- encode this string as Base64
- Set a Header with Authorization: Basic <Base64 encoded username:password>