eclipse-agail / agile-sdk

JavaScript Agile IoT SDK
Eclipse Public License 2.0
2 stars 4 forks source link

add .tokenSet() #30

Closed craigmulligan closed 6 years ago

craigmulligan commented 6 years ago

Connects #25 adds .tokenSet(<token>)

Looks worse than it is, basically just offloaded token management to axios and removed a lot handlers we didn't need.

29 should be merged first.

craigmulligan commented 6 years ago

Hmm, the only method I see returning the whole request is agile.idm.user.delete is that what broke it?

nopbyte commented 6 years ago

As far as I can see. You removed several lines doing this:

.then(res => (res.data))
.catch(errorHandler);

Doesn't this affect somehow? I know that you added something to the axios.interceptors.response, but I don't really know how axios handles this.

did you test the ui after the changes for example?

craigmulligan commented 6 years ago

Yea, but I added a global interceptor to modify the response - see here: https://github.com/Agile-IoT/agile-sdk/pull/30/files#diff-2b4ca49d4bb0a774c4d4c1672d7aa781R4

It's the same as doing it mainly just with less code repetition.

nopbyte commented 6 years ago

Hi @craig-mulligan,

Ok. the issue that I had while testing is in src/idm/authentication.js.

Specifically, I think the problem relates to how we work around the issues that axios has to generate POST with application/x-www-form-urlencoded when interceptors are used. So we were generating a new instance according to this discussion.

This is currently not working after the change.

craigmulligan commented 6 years ago

@nopbyte, thanks for pointing that out. I missed updating the Authentication methods. I've checked all node examples in the /idm everything looks like it's working.