Fixed authentication using Bitbucket (and adding email retrieval)

Fixed authentication using Bitbucket as reported in #34, based on information provided at https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket

Also added support for retrieving e-mail from Bitbucket based on https://confluence.atlassian.com/display/BITBUCKET/emails+Resource#emailsResource-GETalistofuser'semailaddresses
Does that catch the Primary one as most preferred one?
Op 16 sep. 2014 00:37 schreef "Lipis" <notifications@github.com>:

> In main/auth.py:
>
> > @@ -422,7 +426,19 @@ def retrieve_user_from_bitbucket(response):
> >      name = ' '.join((response['first_name'], response['last_name'])).strip()
> >    else:
> >      name = response['username']
> > -  return create_user_db(auth_id, name, response['username'])
> > +  email = ''
> > +  for email_rec in emails:
> > +    if email_rec['active']:
> > +      email = email_rec['email']
> > +      if email_rec['primary']:
> > +        break
>
> email = ''.join([e['email'] for e in emails if e['active']][0:1])
>
> I [image: :heart:] Python!
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/gae-init/gae-init-auth/pull/41/files#r17573514>.
>