Beispiel #1
0
def internal_server_error(e):
    #return render_template('500.html'),500

    # response from oauth_login callback
    resp = yammer_rank_oauth.authorized_response()

    if resp is not None:
        print("DEBUG this is 500 error function!!!!!!!!!!!!!!")
        print("DEBUG resp: {}".format(resp))
        # how to get the code?
        authenticator = yampy.Authenticator(
            client_id=my_constants.CLIENT_ID,
            client_secret=my_constants.CLIENT_SECRET)
        redirect_uri = my_constants.REDIRECT_URL
        auth_url = authenticator.authorization_url(redirect_uri=redirect_uri)
        print("DEBUG auth_url: {}".format(auth_url))
        code = None
        code = request.args.get("code")
        print("DEBUG code: {}, type(code): {}".format(code, type(code)))
        access_token = authenticator.fetch_access_token(code)

        # access_token = (resp['access_token'], '')
        print("DEBUG access_token got: {}".format(access_token))

    return 'auth_bp, 500.html', 500
Beispiel #2
0
    def test_authentication(self):
        authenticator = yampy.Authenticator(
            client_id="valid_client_id",
            client_secret="valid_client_secret",
            oauth_base_url="http://localhost:5000/oauth2",
        )

        access_token = authenticator.fetch_access_token("valid_code")
        self.assertEqual("valid_token", access_token)
Beispiel #3
0
 def __init__(self, config):
     super(YammerAction, self).__init__(config)
     self.client_id = self.config['client_id']
     self.client_secret = self.config['client_secret']
     self.expected_redirect = self.config['expected_redirect']
     self.authenticator = yampy.Authenticator(
         client_id=self.client_id, client_secret=self.client_secret)
     self.access_code = self.config['access_code']
     self.user_info = None
     self.network_info = None
def yammer_login():
    if not app.auth.authorized([], '', request.method):
        return app.auth.authenticate()

    authenticator = yampy.Authenticator(
        client_id="h3V8HGfIF8Cue8QHnJRDJQ",
        client_secret="NihCDhkZU0fszQ0H7ZHG5Gsr7qQGuLhQBrgaBmskl4")
    auth_url = authenticator.authorization_url(
        redirect_uri="http://recommender.oscar.ncsu.edu/api/v2/yammer-login/" +
        str(g.user["_id"]))

    return make_response(
        json.dumps({
            'url': auth_url,
        }), 200, {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "Authorization, Content-Type"
        })
def yammer_login_id(id):
    if "code" in request.args:
        authenticator = yampy.Authenticator(
            client_id="h3V8HGfIF8Cue8QHnJRDJQ",
            client_secret="NihCDhkZU0fszQ0H7ZHG5Gsr7qQGuLhQBrgaBmskl4")
        code = request.args["code"]
        db = app.data.driver.db

        try:
            user = db.users.find_one({"_id": ObjectId(id)})
            if user:
                yammer_access_token = authenticator.fetch_access_token(code)
                db.yammer_tokens.update({"user": user["email"]}, {
                    "user": user["email"],
                    "token": yammer_access_token
                },
                                        upsert=True)

                return redirect("http://localhost:4443/#/status", 201)
            else:
                return redirect("http://localhost:4443/#/status", 401)
        except:
            return redirect("http://localhost:4443/#/status", 401)
currentID = 0
MAX_MSG_LIMIT = 10000000000
currentPgLowerMsgID = MAX_MSG_LIMIT
users = dict()
moreToProcess = True
MAX_MSG_PER_PAGE = 20
restCall = 0  # Keep track of how many times we make web calls due to API limits / throttling
MAX_REQ_PER_INTERVAL = 10  # How many Yammer requests you can make in 30 seconds. Once reached, wait 30 seconds.

# Various Yammer threads for testing
GMAIL_THREAD = 414357831  # 268-ish
AURORA_THREAD = 387871026  # 12 messages
PASTEBIN_THREAD = 421373941  # Exactly 20 messages (as of 27-JUL-2014)

# Setup authenticator - Don't delete any of this! You'll need it when the access token expires
authenticator = yampy.Authenticator(client_id, client_secret)
#auth_url = authenticator.authorization_url(redirect_uri)
#print(auth_url) #Debug: show the code to stdout
#access_token = authenticator.fetch_access_token(code)
#print(access_token)

#Get your Yammer object for making requests
yammer = yampy.Yammer(access_token)

# Create a dictionary from the Yammer messages.

# The RESTful API to the "messages" endpoint will result in one response with two blocks of structures within:
# 1. messages: the actual posts/replies/polls within the message thread
# 2. references: usually users.

# Start by grabbing the latest reply in thread and go backwards from there using message ID.
 def __init__(self):
     self.authenticator = yampy.Authenticator(
         client_id=self.CLIENT_ID, client_secret=self.CLIENT_SECRET)
     self.db_service = DBServiceSocialNetwork()
Beispiel #8
0
 def __init__(self):
     self.authenticator = yampy.Authenticator(client_id=self.CLIENT_ID, client_secret=self.CLIENT_SECRET)
     pass
Beispiel #9
0
import aiml
import yampy
import os
import time

#Authenticate to Yammer

authenticator = yampy.Authenticator(client_id="",client_secret="")
yammer = yampy.Yammer(access_token="")

# Initiate variable new message to constantly check for new private messages
lastmessageid=0
lastmessagesenderid=0
lastmessagecontent="null"

# Create the kernel and learn AIML files
kernel=aiml.Kernel()

# Set working directory
os.chdir("/home/reddowan/Documents/r2d2")

if os.path.isfile("AFR2D2.brn"):
 kernel.bootstrap(brainFile = "AFR2D2.brn")
else:
#load ALICE AIML script, find last version on google. Modify locally to your needs to personalize your bot
 kernel.learn("reduction.names.aiml")
 kernel.learn("reduction0.safe.aiml")
 kernel.learn("reduction1.safe.aiml")
 kernel.learn("reduction2.safe.aiml")
 kernel.learn("reduction3.safe.aiml")
 kernel.learn("reduction4.safe.aiml")
Beispiel #10
0
 def set_client_data(self, client_id, client_secret):
     self.client_id = client_id
     self.client_secret = client_secret
     self.authenticator = yampy.Authenticator(
         client_id=self.client_id, client_secret=self.client_secret)