Ejemplo n.º 1
0
def get_service(what=('drive', 'v2'), credentials=None):
    global _srvc
    if _srvc:
        return _srvc
    if not credentials:
        credentials = creds.get_credentials(CODE, 200)
    http = credentials.authorize(httplib2.Http())
    _srvc = build(*what, http=http)
    return _srvc
Ejemplo n.º 2
0
def access():
    """
    Using the basic credentials, stores in PostgreSQL, gets useful data and "authenticates"
    :return: access token + bearer
    """
    cred = get_credentials()
    res = get_access_token(cred)
    access_token = res['json_data']

    res_for_id = get_facebook_pages(cred)
    ig_id = res_for_id[1]['json_data']['instagram_business_account']['id']
    account_username = res_for_id[0]

    try:
        account = Instagram(username=account_username,
                            access_token=access_token['access_token'],
                            instagram_id=ig_id)
        db.session.add(account)
        db.session.commit()
        return jsonify(res['json_data'])
    except Exception as e:
        return str(e)
Ejemplo n.º 3
0
baseDomain = '<enter base domain here>'
subDomain = '<enter subdomain here>'
record_type = '<enter record type here. A or AAAA>'
ttl = 300
if subDomain is not '':
    fullDomain = subDomain + "." + baseDomain
else:
    fullDomain = baseDomain
if record_type is 'A':
    socktype = socket.AF_INET
elif record_type is 'AAAA':
    socktype = socket.AF_INET6
#end configuration section

#pull credentials from the configured aws-cli tool
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY = creds.get_credentials()

amazonIpCheck = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://icanhazip.com')
if record_type is 'AAAA':
    c.setopt(c.IPRESOLVE, c.IPRESOLVE_V6)
elif record_type is 'A':
    c.setopt(c.IPRESOLVE, c.IPRESOLVE_V4)
c.setopt(c.WRITEDATA, amazonIpCheck)
c.perform()
c.close()

ip = amazonIpCheck.getvalue()

currentValue = socket.getaddrinfo(fullDomain, None, socktype)[0][4][0]