Replace use of = in test by ==
Detect when the URI is wrong
Detect error in password
Use Mechanize generation of the url

The redirect_uri as now to be specified only once.