Skip to main content

Hello Team,

We were using a .Net code to generation API token to access FMEServer in 2015 version, Which was working fine.

Recently we upgraded to FME Server 2019 tried accessing FME server with same source code which was using in FME Server 2015, was throwing an error as "No token was found for user id XXXXX". Could somebody help me to resolve the issue.

 

Also let us know what is the change in token id generation using FME Server 2019? Does we need to update our source code to generate Token with 2019 version?

 

Thanks in Advance!!!

How exactly are you currently trying to generate the token? Can you post an example?


How exactly are you currently trying to generate the token? Can you post an example?

Hi David,

Thanks for your prompt responce.

Following was the function we used to call token code from FME Server 2015,

private string GetToken(string username, string password)

{

var token = new RestRequest("/fmetoken/service/view.json", Method.POST);

token.AddParameter("user", username);

token.AddParameter("password", password);

return SafeRestAndWebExecute<FmeResponse>(token).serviceResponse.token;

}

Client Server details we were passing from configuration file.

Thanks..


How exactly are you currently trying to generate the token? Can you post an example?

Hello David,

Refer following examples as well from postman,

 

FME Server 2015

http://servertest/fmetoken/service/view.json?user=usr&password=pwd

{

"serviceResponse": {

"token": "09ac59e8b141a1eead8fe0c19e191022557818b7",

"expirationDate": "2020-05-12 23:58:42",

"clientAddress": ""

}

}

 

FME Server 2019

http://servernew/fmetoken/service/view.json?user=usr&password=pwd

{

"serviceResponse": {

"statusInfo": {

"message": "No token was found for user ID: \\usr\\"",

"status": "failure"

}

}

}


I could reproduce the issue with FME Server 2020. It seems the way you're doing it with FME 2015 has either been deprecated, or was never really officially supported (it looks a bit weird to me, at least).

The good news is that it is relatively easy to fix the token request, here's an example that works for generating a token that's valid 1 day:

Two things to notice compared to your existing solution:

  1. The URL is slightly different
  2. The username, password, etc are sent in the message body, not as URL query strings

For reference, the Content-Type header is set to "application/x-www-form-urlencoded"

There's also a fairly complete Javascript example here, under the heading "Generating a token": https://playground.fmeserver.com/getting-started/authentication/


Looking at bit further, I see that the main problem is that you're calling the "view.json" endpoint, which seems to exist for looking up an existing token. This was probably not strictly enforced before, and I'm guessing that it would automatically generate a new token if no existing token was found. This seems to no longer be the case, and it now returns an error if no existing token is available.

You can simply fix this in your existing code by replacing "view.json" with "generate.json" in the URL. Then it should work with no further changes.


I could reproduce the issue with FME Server 2020. It seems the way you're doing it with FME 2015 has either been deprecated, or was never really officially supported (it looks a bit weird to me, at least).

The good news is that it is relatively easy to fix the token request, here's an example that works for generating a token that's valid 1 day:

Two things to notice compared to your existing solution:

  1. The URL is slightly different
  2. The username, password, etc are sent in the message body, not as URL query strings

For reference, the Content-Type header is set to "application/x-www-form-urlencoded"

There's also a fairly complete Javascript example here, under the heading "Generating a token": https://playground.fmeserver.com/getting-started/authentication/

Thanks David for your support.


Reply