7

When I try to follow this tutorial to install Google-auth2 on my Django 1.4 I get this error:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    import settings
  File "/home/ubuntu/xx/settings.py", line 140, in <module>
    GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID']
NameError: name 'os' is not defined

This line is:

139- LOGIN_REDIRECT_URL = '/'

**140- GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID']**

141- GOOGLE_OAUTH2_CLIENT_SECRET = os.environ['GOOGLE_OAUTH2_CLIENT_SECRET']
142- GOOGLE_WHITE_LISTED_DOMAINS = ['mydomain.org']
SOCIAL_AUTH_USER_MODEL = 'auth.User'
4

1 に答える 1

34

You try to use something from module os, which is not imported, thus you cannot use it.

In order to fix this problem, add an import of that module somewhere at the beginning of settings.py:

import os

Additionally, if you don't have GOOGLE_OAUTH2_CLIENT_ID in os.environ, don't load it from there. Instead, set it directly in settings.py:

GOOGLE_OAUTH2_CLIENT_ID = 'your-actual-client-id-value'

Or, you can set it first, in your shell, before running the script:

export GOOGLE_OATH2_CLIENT_ID='your-actual-client-id-value'
于 2012-08-04T11:43:11.693 に答える