Package openid :: Package consumer :: Module consumer :: Class AuthRequest
[frames] | no frames]

Class AuthRequest

source code

object --+
         |
        AuthRequest

An object that holds the state necessary for generating an OpenID authentication request. This object holds the association with the server and the discovered information with which the request will be made.

It is separate from the consumer because you may wish to add things to the request before sending it on its way to the server. It also has serialization options that let you encode the authentication request as a URL or as a form POST.

Instance Methods
 
__init__(self, endpoint, assoc)
Creates a new AuthRequest object.
source code
 
setAnonymous(self, is_anonymous)
Set whether this request should be made anonymously.
source code
 
addExtension(self, extension_request)
Add an extension to this checkid request.
source code
 
addExtensionArg(self, namespace, key, value)
Add an extension argument to this OpenID authentication request.
source code
openid.message.Message
getMessage(self, realm, return_to=None, immediate=False)
Produce a openid.message.Message representing this request.
source code
str
redirectURL(self, realm, return_to=None, immediate=False)
Returns a URL with an encoded OpenID request.
source code
 
formMarkup(self, realm, return_to=None, immediate=False, form_tag_attrs=None)
Get html for a form to submit this request to the IDP.
source code
 
htmlMarkup(self, realm, return_to=None, immediate=False, form_tag_attrs=None)
Get an autosubmitting HTML page that submits this request to the IDP.
source code
bool
shouldSendRedirect(self)
Should this OpenID authentication request be sent as a HTTP redirect or as a POST (form submission)?
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, endpoint, assoc)
(Constructor)

source code 

Creates a new AuthRequest object. This just stores each argument in an appropriately named field.

Users of this library should not create instances of this class. Instances of this class are created by the library when needed.

Overrides: object.__init__

setAnonymous(self, is_anonymous)

source code 

Set whether this request should be made anonymously. If a request is anonymous, the identifier will not be sent in the request. This is only useful if you are making another kind of request with an extension in this request.

Anonymous requests are not allowed when the request is made with OpenID 1.

Raises:
  • ValueError - when attempting to set an OpenID1 request as anonymous

addExtension(self, extension_request)

source code 

Add an extension to this checkid request.

Parameters:
  • extension_request - An object that implements the extension interface for adding arguments to an OpenID message.

addExtensionArg(self, namespace, key, value)

source code 

Add an extension argument to this OpenID authentication request.

Use caution when adding arguments, because they will be URL-escaped and appended to the redirect URL, which can easily get quite long.

Parameters:
  • namespace (str) - The namespace for the extension. For example, the simple registration extension uses the namespace sreg.
  • key (str) - The key within the extension namespace. For example, the nickname field in the simple registration extension's key is nickname.
  • value (str) - The value to provide to the server for this argument.

getMessage(self, realm, return_to=None, immediate=False)

source code 

Produce a openid.message.Message representing this request.

Parameters:
  • realm (str) - The URL (or URL pattern) that identifies your web site to the user when she is authorizing it.
  • return_to (str) - The URL that the OpenID provider will send the user back to after attempting to verify her identity.

    Not specifying a return_to URL means that the user will not be returned to the site issuing the request upon its completion.

  • immediate (bool) - If True, the OpenID provider is to send back a response immediately, useful for behind-the-scenes authentication attempts. Otherwise the OpenID provider may engage the user before providing a response. This is the default case, as the user may need to provide credentials or approve the request before a positive response can be sent.
Returns: openid.message.Message

redirectURL(self, realm, return_to=None, immediate=False)

source code 

Returns a URL with an encoded OpenID request.

The resulting URL is the OpenID provider's endpoint URL with parameters appended as query arguments. You should redirect the user agent to this URL.

OpenID 2.0 endpoints also accept POST requests, see shouldSendRedirect and formMarkup.

Parameters:
  • realm (str) - The URL (or URL pattern) that identifies your web site to the user when she is authorizing it.
  • return_to (str) - The URL that the OpenID provider will send the user back to after attempting to verify her identity.

    Not specifying a return_to URL means that the user will not be returned to the site issuing the request upon its completion.

  • immediate (bool) - If True, the OpenID provider is to send back a response immediately, useful for behind-the-scenes authentication attempts. Otherwise the OpenID provider may engage the user before providing a response. This is the default case, as the user may need to provide credentials or approve the request before a positive response can be sent.
Returns: str
The URL to redirect the user agent to.

formMarkup(self, realm, return_to=None, immediate=False, form_tag_attrs=None)

source code 

Get html for a form to submit this request to the IDP.

Parameters:
  • form_tag_attrs ({unicode: unicode}) - Dictionary of attributes to be added to the form tag. 'accept-charset' and 'enctype' have defaults that can be overridden. If a value is supplied for 'action' or 'method', it will be replaced.

htmlMarkup(self, realm, return_to=None, immediate=False, form_tag_attrs=None)

source code 

Get an autosubmitting HTML page that submits this request to the IDP. This is just a wrapper for formMarkup.

Returns:
str

See Also: formMarkup