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 | |
callAPI | Call an API protected by OAuth. |
getToken | Perform a token request. |
makeOAuthHandler |
Properties inherited from class Client | |
cust_id | |
mode | |
secret | |
signature_method | |
use_header | Should we use the header field? |
version | |
Methods inherited from class Client | |
callAPI | Call an API protected by OAuth. |
getToken | Perform a token request. |
makeOAuthHandler | |
makeSecret | Signature key-string generator. |
parseQS | Static utility to parse a query string into a dictionary of values. |
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. |
Return | The raw data returned by the remote OAuth procedure. |
Calls a remote web API and blocks until a result is available.
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. | ||
Return | A new Token created through this call. | ||
Raise |
|
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( address, oauth_params, params )