Closed betyar closed 10 months ago
I am having trouble obtaining a token. I keep getting a 405 error "invalid code". I can receive the authorization code no problem, but when the program tries to obtain the token it fails. This problem not only exists with my code, but the LoginDemo as well. I have setup everything correctly thus far because oauth.createLoginUrl returns what it's supposed to. But when this info is then used by oauth.getToken the response is a status 200, error 405, msg "invalid code" , and an empty data object. Am I using the correct parameter from the redirectUrl (authorization) or should something else be included?
Here are the parameters I received from redirectUrl (formatted for easier reading):
"clientId":"EGKosLVlG2g8JQMhG9WiLfqk2Bna7MjY" "redirectUrl":"http://127.0.0.1:8000/redirectUrl" "grantType":"authorization_code" "state":"001" "nonce":"vqxon96g" "seq":"1692788376876" "authorization":"WZGJSaKW9w1D5bMy6dzTufIX1up/mNUWT8gqE8u4xvg"}
This is the response when trying to get the token:
"status":200 "responseTime":481 "error":405 "msg":"invalid code" "data":{}}
Thanks in advance for any help you can provide.
OAuth.getToken({xxxx}) needs to fill in the code that the page will carry after logging in, and its effective time is only 30 seconds (which may be shorter in actual situations).
Many thanks for your quick reply. I don't think the problem is with the code because I get the exact same result when trying to run eWeLinkOAuthLoginDemo. I have tried on a Synology NAS as well as a Raspberry Pi but no luck.
Many thanks for your quick reply. I don't think the problem is with the code because I get the exact same result when trying to run eWeLinkOAuthLoginDemo. I have tried on a Synology NAS as well as a Raspberry Pi but no luck.
https://drive.google.com/file/d/1N4KM7ZjBvW8Zj0ZUG0SfMUEtJ1Npr-aK/view?usp=sharing
This is my sample operation video
I am having trouble obtaining a token. I keep getting a 405 error "invalid code". I can receive the authorization code no problem, but when the program tries to obtain the token it fails. This problem not only exists with my code, but the LoginDemo as well. I have setup everything correctly thus far because oauth.createLoginUrl returns what it's supposed to. But when this info is then used by oauth.getToken the response is a status 200, error 405, msg "invalid code" , and an empty data object. Am I using the correct parameter from the redirectUrl (authorization) or should something else be included?
Here are the parameters I received from redirectUrl (formatted for easier reading):
"clientId":"EGKosLVlG2g8JQMhG9WiLfqk2Bna7MjY" "redirectUrl":"http://127.0.0.1:8000/redirectUrl" "grantType":"authorization_code" "state":"001" "nonce":"vqxon96g" "seq":"1692788376876" "authorization":"WZGJSaKW9w1D5bMy6dzTufIX1up/mNUWT8gqE8u4xvg"}
This is the response when trying to get the token:
Thanks in advance for any help you can provide.