Skip to content

Live server using OAuth

Craig M. Stimmel edited this page Mar 2, 2021 · 5 revisions

This still needs documentation for setting up the views/templates required for 3-legged oauth.

Spotseeker Settings

Edit the following in your .env file:

AUTH_MODULE=oauth
SPOTSEEKER_AUTH_ADMINS=demo_user,javerage

The SPOTSEEKER_AUTH_ADMINS setting is a list that defines the admin users that can modify server data (PUT, POST, DELETE).

To create new clients, run this command in the spot seeker project (use '--trusted' flag for a trusted consumer for spot create or edit):

python manage.py create_consumer

To run this command in a running Docker container, do the following:

docker exec -it spotseeker-server bin/python manage.py create_consumer

After entering the consumer name and copying the key and secret, exit the interactive terminal using the command exit. The name it prompts you for will be shown to users in 3-legged auth. Track the key and secret somewhere secure. Note: At this time this command will need to be re-run on each restart of the spotseeker-server container. (#TODO: fix with persistent db)

Running with Scout or Scout Manager

If trying to run scout or scout-manager live against Spotseeker Server, copy the oauth consumer key and secret into the respective .env files. Make sure these two lines are uncommented in your .env file and are set to the correct values:

SPOTSEEKER_OAUTH_KEY=<yourkey>
SPOTSEEKER_OAUTH_SECRET=<yoursecret>

Make sure the OAUTH_USER setting in scout-manager also matches a user in spotseeker-server's AUTH_USERS. To set this, go to your .env file and set the following variable to the correct value:

OAUTH_USER=demo_user

Optional Logging

To enable logging that includes oauth app and user info add this to your settings.py:

In LOGGING:

'loggers': {
    'spotseeker_server.logger.oauth': {
        'handlers': ['console'],
        'level':'INFO',
    }
},
'handlers': {
    'console': {
        'level':'INFO',
        'class':'logging.StreamHandler',
    },
}