예제 #1
0
def oauthAccessToken():

  result = gOAManager.authorizeFlow( checkRequest = True, checkVerifier = True )
  if not result[ 'OK' ]:
    gLogger.info( "Not authorized request: %s" % result[ 'Message' ] )
    bottle.abort( 401, "Not authorized: %s" % result[ 'Message' ] )
  oaData = result[ 'Value' ]

  result = gOAManager.credentials.generateToken( gOAData.consumerKey,
                                                  gOAData.requestToken,
                                                  gOAData.verifier )
  if not result[ 'OK' ]:
    bottle.abort( 401, "Invalid verifier: %s" % result[ 'Value' ] )
  tokenData = result[ 'Value' ]

  reqToken = oauth2.Token( tokenData[ 'token'], tokenData[ 'secret' ] )
  return reqToken.to_string()
예제 #2
0
def oauthRequestToken():

  result = gOAManager.authorizeFlow()
  if not result[ 'OK' ]:
    gLogger.notice( "Not authorized request: %s" % result[ 'Message' ] )
    bottle.abort( 401, "Not authorized: %s" % result[ 'Message' ] )

  callback = gOAData.callback
  if callback == 'oob':
    callback = ""

  result = gOAManager.credentials.generateRequest( gOAData.consumerKey, callback )
  if not result[ 'OK' ]:
    bottle.abort( 500, result[ 'Message' ] )
  tokenData = result[ 'Value' ]
  reqToken = oauth2.Token( tokenData[ 'request' ], tokenData[ 'secret' ] )
  reqToken.set_callback( tokenData[ 'callback' ] )

  return reqToken.to_string()