We are getting a 200 OK now, but we are not being redirected to the redirect_uri and receiving an access token ... so clearly something is going wrong. The reason we are trying to put the payload into the data is because it was specified that it needs the input as FORM parameters.
Any other ideas as to what is going wrong??? It is not getting redirected at all but it seems like the request is going through...
From what I see you still putting parameters to the body. "data=payload" is the body. I don't know where it is specified but if it is not URI parameters you will not get anything.
response = requests.post(url+'?'+payload, data='', headers=header, verify=False)
Now you get better response as luan_ngo but he hasn't figured it our yet and our support guys also not replying when it can happen. Can you remove state parameter completely, you actually don't need it.
Can you post full Uri including real code and all parameters after it is built?
Removed the status parameter and it is not helping. I don't understand why it is returning 200 when it doesn't redirect properly ... and why when it fails it fails.
Hopefully the error messages quality can be improved so we have a better idea as to what is going on. We need to move on to the rest of the app development so getting the access_token would be GREAT!!!
Added the following 2 headers:
'Authorization':'Basic ' + encoded_string
Tried requesting with 'Content-type' : 'application/x-www-form-urlencoded' as well for the same results.
So essentially we are getting 200 OK requests when we request through the code with content-type set to atom+xml but start failing at x-www-form-urlencoded even though that is what we are supposed to be sending in?
Is there something wrong with the format we are requesting it in?
You suppose to send atom+xml but in this case I don't think it is critical as you don't actually send any content. I still have the feeling that your parameters are posted as form data in the body. They should be part of URI
So, you don't get error now? You get 200 with no tokens? In this case it may be if the code is wrong or expired (I think I experienced that when I sent wrong code but I am not sure)
Request seems to be ok. I also just checked the server, it works. Status code 0 from what I found on internet:
status 0 appear when an ajax call was cancelled before getting the response by refreshing the page or requesting a URL that is unreachable.
this status is not documented but exist over ajax and makeRequest call's from gadget.io.
Guys it finally worked!! I got an access_token and a refresh_token!!! Finally!!!! :D Thanks a lot yshteinm and JBilkey!
Now that I am finally in possession of this magical token of glory, am I able to finally use it to unlock the gates of Mordor? Can I at the very least request data?? I am looking at the other requests and it seems like the GET call for data does not use this token, it takes in an AuthKey of customer's application (which is the token perhaps?). I just did a quick test for that and I am getting a 500 error from the server while it throws a NullPointerException.
I'm positive I'm missing something very tiny before I can finally taste sweet victory over this data, any idea??
Also, was going through the flow again to get the access_token and it looks like it is only possible if you do it from step 1 and not just in separate pieces (so if you login and get redirected then get the code and everything ... not just getting the code?) It starts giving me 400's and syntactically incorrect requests if I do that
Thanks again for all the useful suggestions and tips.
There were two problems before:
a) we were getting a 200 OK with no access_token -- we thought the problem might be in our requesting library so we changed it
b) we were getting a 404 or a 500 -- we thought the problem was our request itself, so we were trying to modify it
That is the #4 GET EUI data request. How does this differ from #6 Request EUI? Request EUI has an extra parameter (type) and is a POST not a GET. Trying #4 GET though I get a 200OK but no data ... lol. This seems to be a reoccurring theme. The request I am sending is:
GET /ldc/api/v1/UsagePoint?duration=15897600&start=1364788800 HTTP/1.1
@yshteinm D'oh ):
Lack of sleep I guess. Completely did not notice that lol. What is the refresh token for? After how long does the data expire? The GET call does work for me though :)
Also, I tried the #6 request (Request EUI) and I get a NullPointerException for that -- same parameters as above and I added in type='data'. I tried both with FORM parameters and URL params in a POST request for the same result.