No code returned from Wink API

Trying to setup my wink hub. followed examples and read threads can not find anything on this error. When on I follow link “http://192.168.0.107:8123/auth/wink/callback” I get the response
“No code returned from Wink API”

You shouldn’t be hitting auth/wink/callback directly, you should get redirected there.

Are you trying to connected to “auth/wink” or “auth/wink/callback”?

You need to directly connect to “auth/wink” first and after you authentication you will automatically get redirected to “auth/wink/callback”

Step 1:
I opened developer account with Wink entered a callback url and got a client ID and a client Secret

redirecturl1

Step 2:
Entered client ID and client Secret in config box on home assistant states screen and then got this box

visit

When I viisited “http://oravec.duckdns.org:8123/auth/wink” got this

mot_auth

Tried it with ip address “http://192.168.0.107:8123/auth/wink” ad got the same error

Tried adding callback to url “http://192.168.0.107:8123/auth/wink/callback” and got the error “No code returned from Wink API”

Tried using the legacy method with no luck either

Are you performing this from the same network as your HA box?

Yes on I am on the same network as HA

Email and password in configuration file works but client ID/ client Secret does not

When you go to http://192.168.0.107:8123/auth/wink after it redirects, can you copy the URL on that page and share it here?

this is the url of page that it directs me to::

https://api.wink.com/oauth2/authorize?client_id=-yexK2Ei3sWJaP_xbNTSBQuyLkx35y7f&redirect_uri=http%3A//oravec.duckdns.org%3A8123/auth/wink/callback

This what is on page:

mot_auth

Thats what I thought so, try adding http://oravec.duckdns.org:8123/auth/wink/callback to the call backs in your developer.wink.com account.

I don’t know where HA is pulling that URL from…

You could also replace the “oravec.duckdns.org” part of the url with 192.168.0.107 and try hitting that.

I had a slash “/” after the word callback on the Wink developer site removed it and everything seems to work

Thank you for your help noticed it after your post

1 Like

I’m having a similar problem. I’m using duckdns and SSL, so when I go to https://192.168.1.60:8123/auth/wink/ I get no code returned from Wink API with the expected SSL error and if I go to https://something.duckdns.org:52006/auth/wink I get spinning circle. I check for the extra ‘/’ and I don’t have it. Since I’m using SSL I can’t access http to follow the instructions to the letter, correct?

I ended up having to disable SSL temporarily to get this to work. Not sure if there was a better way or not but now that it’s setup I’m good to go right? Should I be worried that the redirect URL in the Wink developer’s portal is the public duckdns URL? If I change it back to local will it break?

Yeah I am not sure if there is a way around it or not. Feel free to mess around with it and update the docs if you figure it out. Might be worth adding something about disabling it temporarily as an option.

The redirect URI is only every used during the initial setup. So as long as your token doesn’t go a long time without getting refreshed (you have HA off for a super long time) or you accidentally delete the .wink.conf file you are good to go.

1 Like

I had a similar problem authenticating with Wink this weekend. There were two problems. The first is that I had “base_url” set for the HTTP component, and that URL is what the Wink configuration directed me to in the “Please authorize Wink” dialog. After (temporarily) changing that to the local IP address, the authorize dialog directed me to the right place, but I got the “Redirect URI is not authorized”. After much fiddling around, I used a different browser that didn’t have any cached info for my HA site, and got success! So I’m assuming that there was a browser caching issue that could have been resolved by clearing the browser’s cache, but I didn’t follow it up further.

The key point is that “base_url” needs to match what was set up for “redirect URI”, at least in terms of protocol (HTTP/HTTPS), DNS/IP (192.168.x.x), and port (8123)

1 Like

I was seeing the correlation to the base URL too. I was thinking at first it was taking it from the website registered with Wink. I got frustrated as nothing I did on Wink site changed the URL they sent back, I was worried I’d need to apply for another application or something. After disabling SSL, and using the base URL over http I was good to go. Not for the faint of heart and more than a noob coming from Wink may do…