Closed dburk1013 closed 7 years ago
I found or have been helped with the answers to all 3 so this can be closed. 1) I understand that, even though getting the authorization token is in a "POST", apparently the Tesla servers are still expecting the parameters to be passed on the URL line. I wish it weren't so, but maybe there's no alternative. 2) If there is no output to go to Tesla (as there wouldn't be with a "GET"), the myURLConnection.setDoOutput(true) results in a 404 error. If you have a GET type, seems the setDoOutput(true) creates a problem. Remove the line and it works! 3) .setConnectTimeout and .setReadTimeout changes show as properties of myURLConnection.delegate.client. You have to dig deep enough to see the changes.
Thanks to everyone who had any thoughts on any of this.
Thanks to a number of contributors who are much wiser than I, I've got a plain vanilla version of what I'm trying to do in Java working in EclipseJavaNeon. But ultimately, I'm trying to get this into an Android app. The goal is ultimately to close an open (or vented) sunroof. There is something about how I'm using the API that's just not right (or I'm just too uneducated to be programming this stuff). There are two parts to my problem right now and a kind of third problem listed way below.
1) On the effort to get the access token, I can get the token but only if all the parameters are in the URL itself with https://private-anon-3f2af7cab3-timdorr.apiary-proxy.com/oauth/token?client_id=e4a9949fcfa04068f59abb5a658f2bac0a3428e4652315490b659d5ab3f35a9e&client_secret=c75f14bbadc8bee3a7594412c31416f8300256d7668ea7e6e7f06727bfb9d220&email=myemail@hotmail.com&password=[my password]&grant_type=password
This works but it seems as if I should be able to pass the parts either as JSON or the equivalent of headers so that it's not passed in plain text with the password. Here's the code that I'm using. This is in a separate thread as required by Android and I THINK I'm managing the Async stuff correctly. So the following works but I'd like to get the parameters out of the URL if there's a way to do it:
2) Once I have a good access token, I'm next trying to get the vehicleID. The following code is returning a 404 from the server. I suspect I'm missing something really easy and obvious. Any help here again would be greatly appreciated:
3. If anyone has any thoughts about why the .setConnectTimeout and .setReadTimeout methods don't seem to be changing the values for the properties when I'm looking the debugger either for myURLConnection or for the delegate property of myURLConnection, again, I would appreciate your ideas. As a related item, I learned that the .setRequestMethod, .setDoOutput, and .setDoInput methods don't change these properties for myURLConnection but do set these properties for the delegate, but this doesn't happen for the . ...Timeout methods. Why?
THANK YOU!