During the user authorization process, to obtain the code, need to send a “redirect_uri” to the server. It’s a URL where you receive the code. After user authorization, the client browser will redirect to this URL with parameter code, thus you can get the code. For example, the “redirect_uri” parameter sent to is "http://www.oauth.net:8080/token.htm", the final redirect URL will be something like this: http://www.oauth.net:8080/token.htm?code=0***x.
The domain name or top-level domain of “redirect_uri” needs to be consistent the callback URL defined in console
Before you release you application to production, you may not have the callback URL available in Internet. Then how can we get the code from callback URL?
One way to achieve this is to change your local host binding (in hosts file). If you check the image above, you will find oauth.net. Actually this is not owned by me, it’s the official side of oauth protocol. But in my local host binding, I’ve bound this domain (www.oauth.net) to 127.0.0.1. So even I set the redirect_uri to http://www.oauth.net:8080/token.htm, it will eventually redirect to the page (token.htm) on my local server.