ibm-early-programs / node-red-contrib-watson-machine-learning

Apache License 2.0
2 stars 9 forks source link

Access token requested every call #13

Open johnhmacleod opened 6 years ago

johnhmacleod commented 6 years ago

It seems that this node requests a token every time it is invoked. Is that necessary? Can this be optimised? Maybe check for an expired token error code & regenerate or refresh when needed. Otherwise there are 2 API calls per invocation. I've been unable to find out how long tokens last!

chughts commented 6 years ago

Seems like a good idea to cache the token. Would need a mechanism to determine when the token does expire. Am happy to accept a pull request.

johnhmacleod commented 6 years ago

The mechanism would be to check the return code I believe.

https://dataplatform.cloud.ibm.com/docs/content/troubleshoot/ml_troubleshooting.html#ts_expired_authorization_token

Return code 401.

johnhmacleod commented 6 years ago

Love to, but likely well beyond my JS (& RED) skills to implement that!