Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Created April 22, 2016 15:42
Show Gist options
  • Select an option

  • Save b4ldr/d78ff0f6e064f98aaf2e41b95b46085b to your computer and use it in GitHub Desktop.

Select an option

Save b4ldr/d78ff0f6e064f98aaf2e41b95b46085b to your computer and use it in GitHub Desktop.
import os
import gitlab
import psycopg2
from pwd import getpwnam
def get_auth_token():
os.setuid(getpwnam('gitlab-psql').pw_uid)
conn = psycopg2.connect(
host='/var/opt/gitlab/postgresql',
database='gitlabhq_production')
cur = conn.cursor()
cur.execute('select authentication_token from users where admin = %s limit 1', 't')
key = cur.fetchone()[0]
conn.close()
return key
g = gitlab.Gitlab('http://127.0.0.1:8181', get_auth_token(), ssl_verify=False)
g.auth()
g..projects.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment