Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You must define 'CONTACTS_IMPORT_CALLBACK' in settings #1

Open
mrbm opened this issue Sep 7, 2010 · 1 comment
Open

You must define 'CONTACTS_IMPORT_CALLBACK' in settings #1

mrbm opened this issue Sep 7, 2010 · 1 comment

Comments

@mrbm
Copy link

mrbm commented Sep 7, 2010

I was trying to use this with pinax, but couldn't find any documentation stating what 'CONTACTS_IMPORT_CALLBACK' should be set to....any ideas? Or is this an error. Also of note as I noticed that the developers of this are involved with pinax...the bbauth seems to be in the process of being depreciated, so even after properly setting up an bbauth app, there is no app that has any permissions to interact with the 'contacts' of a yahoo account giving a 403 error. Look forward to hear the solution gentlemen. Good day.

@braskin
Copy link

braskin commented Feb 7, 2011

You can't use BBAuth any more. It is deprecated. The pinax contact importer is kind of out of date.

django-contacts-import Google contact import works out of the box

For Yahoo, you need to go to Yahoo dev, create a new project with read access to Contacts.

django-contacts-import seems to assume that you already have a Yahoo Oauth done and have an access token. The Yahoo contact importer also has a strange dependency on django-oauth-access, but only for the Yahoo import and mostly for things that you can do pretty easily with oauth2 yourself.

If it helps anyone... Here is some code that I added to views.py to add Yahoo Oauth. It is ugly, but maybe it can save you some time:

def yahoo_login(request, redirect_to=None):
    consumer = oauth.Consumer(settings.YAHOO_CONSUMER_KEY, settings.YAHOO_CONSUMER_SECRET)

    if request.GET == {}:
        client = oauth.Client(consumer)
        callback_url = 'http://www.playdation.net/contacts/yahoo/login'
        request_token_url = 'https://api.login.yahoo.com/oauth/v2/get_request_token'

        resp, content = client.request(request_token_url, method="GET", callback_url=callback_url)

        response_dict = dict(cgi.parse_qsl(content))

        if ((str(resp['status']) != '200') or ('oauth_problem' in response_dict)):
            raise Exception("CANT GET REQUEST TOKEN"+str(response_dict))

        request.session['yahoo_token'] = response_dict

        authenticate_url = 'https://api.login.yahoo.com/oauth/v2/request_auth'    

        url = "%s?oauth_callback=%s&oauth_token=%s" % (authenticate_url, callback_url, request.session['yahoo_token']['oauth_token'])
        return HttpResponseRedirect(url)
    elif request.GET['oauth_verifier'] != '':
        verifier = request.GET['oauth_verifier']
        token = oauth.Token(request.session['yahoo_token']['oauth_token'],request.session['yahoo_token']['oauth_token_secret'])
        token.set_verifier(verifier)
        client = oauth.Client(consumer, token)
        access_token_url='https://api.login.yahoo.com/oauth/v2/get_token'
        resp, content = client.request(access_token_url, "GET")
        if str(resp['status']) != '200':
            raise Exception("CANT GET ACCESS TOKEN")
        access_token = dict(cgi.parse_qsl(content))

        token = oauth.Token(access_token['oauth_token'], access_token['oauth_token_secret'])

        request.session['yahoo_token'] = token.to_string()

    if redirect_to is None:
        redirect_to = reverse("import_contacts")
    return HttpResponseRedirect(redirect_to)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants