Skip to content

separate repository from Ajapaik-web for Wikimedia OAUTH and image uploading

License

Notifications You must be signed in to change notification settings

Ajapaik/ajapaik-mwapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ajapaik-mwapi

separate repository from Ajapaik-web for Wikimedia OAUTH and image uploading

Install

> git clone [email protected]:Ajapaik/ajapaik-mwapi.git
> cd ajapaik-mwapi
> python3 -m venv venv
> source venv/bin/activate
> venv/bin/python3 -m pip install --upgrade pip
> pip install -r requirements.txt
> cd src
> cp server/settings/local.example.py server/settings/local.py

Edit local configuration to server/settings/local.py

  • USE_BETA_COMMONS defines if we are using Wikimedia production or Beta-cluster. Use Beta for developing.
  • SECRET_KEY value is long random string
  • CSRF_TRUSTED_ORIGINS and ALLOWED_HOSTS should match to your hostname if it is other than localhost
  • SOCIAL_AUTH* = Oauth1 consumer settings. See My first Django OAuth tool for more info.

Register OAUTH1 consumer

To request changes to the software configuration, the creation of new Beta Cluster wikis or user rights, please file a task in Phabricator. If you are doing more testing then you can request Oauth approval rights to beta cluster for yourself.

Oauth consumer proposal checklist

  • Oauth version: OAuth 1.0a consumer
  • Application name: use a name that indicates that you are developing locally
  • Leave "This consumer is for use only by " unchecked
  • Contact email address: Use a valid email where you can be reached.
  • Applicable project: All is fine
  • OAuth "callback" URL: http://127.0.0.1:8000/
  • Select: Allow consumer to specify a callback in requests and use "callback" URL above as a required prefix.
  • Types of grants being requested: (for uploading photos) .* Edit existing pages .* Create, edit, and move pages .* Upload new files .* Upload, replace, and move files
  • Public RSA key: You can leave this empty at the moment.

Run migrations

> python manage.py makemigrations webservice
> python manage.py migrate

## Start test server
> python manage.py runserver 8000

Open https://127.0.0.1:8000/ with browser and do OAUTH login.

Port forwarding

Making server visible on the public internet. Example only (command needs to be edited to get it working)

> sudo -u username ssh -N -L 8000:127.0.0.1:8000 [email protected] -i /home/username/.ssh/id_rsa

Management commands

This will show users logged in

> python manage.py userinfo 

This will upload one random image from Wikimedia Commons to Beta Commons

> python manage.py uploadtest  

Reseting the database

> rm src/server/db.sqlite3
> rm -rf src/webservice/migrations/*
> python manage.py makemigrations webservice
> python manage.py migrate

URLS

REST API

About

separate repository from Ajapaik-web for Wikimedia OAUTH and image uploading

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages