Fix bugs in bitbucket authentication.