24.1Class Client

Interface to remote OAuth2 authentication process server.

Class Client( consumer_key, cust_id, cust_secret, [mode] ) from \
                 web.oauth.Client(( cust_id, cust_secret, mode))
consumer_key The consumer key identifying the requester on the remote OAuth2 server.
mode One of the Via methods (Defaults to POST).

This class acts as an authentication client connecting with a remote server.

Properties
version
Methods
callAPICall an API protected by OAuth.
getTokenPerform a token request.
makeOAuthHandler
Properties inherited from class Client
cust_id
mode
secret
signature_method
use_headerShould we use the header field?
version
Methods inherited from class Client
callAPICall an API protected by OAuth.
getTokenPerform a token request.
makeOAuthHandler
makeSecretSignature key-string generator.
parseQSStatic utility to parse a query string into a dictionary of values.

Properties

version

Methods

callAPI

Call an API protected by OAuth.

callAPI( token, uri, [params] )
token An instance of Token.
uri The URI of the remote OAuth protected Web API to be called.
params Optional parameters for the call.
ReturnThe raw data returned by the remote OAuth procedure.

Calls a remote web API and blocks until a result is available.

getToken

Perform a token request.

getToken( address, callback, code )
address The address of the remote token provider.
callback Address to be called back by authenticator if the caller is of a web application.
code A code received calling the authorize uri.
ReturnA new Token created through this call.
Raise
ProtoError if the remote side doesn't complain with the OAuth protocol.

This method requests an "Access token" the remote OAuth service.

For example, a theoretic workflow may be


      import from web.oauth in oauth

      code = Reply.redirect("https://TheRemoteService/oauth/authorize",0)

      //the GET parameters that must be passed are: client_id and redirect_uri.

      //An important thing is that the redirect_uri and the callback parameter passed in the getToken function must be the same!

      client = oauth.Client( "MyClientID", "MyClientSecret" )
      access_token = client.getToken( "https://TheRemoteService/oauth/access_token", callback,code )

      userData = client.callAPI( access_token,
                  "https://TheRemoteService/get_user",
                  ["user_id"=> my_user_id] )

Note: This method blocks until the remote side replies.

makeOAuthHandler

makeOAuthHandler( address, oauth_params, params )
Made with http://www.falconpl.org