QOAuth  1.0.1
Classes | Typedefs | Enumerations | Functions
QOAuth Namespace Reference

This namespace encapsulates all classes and definitions provided by libqoauth.

Classes

class  Interface
 This class provides means for interaction with network services supporting OAuth authorization scheme. More...
 

Typedefs

typedef QMultiMap< QByteArray,
QByteArray > 
ParamMap
 A typedef for the data structure for storing request parameters.
 

Enumerations

enum  SignatureMethod { HMAC_SHA1, RSA_SHA1, PLAINTEXT }
 This enum type describes the signature method used by the request. More...
 
enum  HttpMethod {
  GET, POST, HEAD, PUT,
  DELETE
}
 This enum type specifies the HTTP method used for creating a Signature Base String and/or sending a request. More...
 
enum  ParsingMode { ParseForRequestContent, ParseForInlineQuery, ParseForHeaderArguments, ParseForSignatureBaseString }
 This enum type specifies the method of parsing parameters into a parameter string. More...
 
enum  ErrorCode {
  NoError = 200, BadRequest = 400, Unauthorized = 401, Forbidden = 403,
  Timeout = 1001, ConsumerKeyEmpty, ConsumerSecretEmpty, UnsupportedHttpMethod,
  RSAPrivateKeyEmpty = 1101, RSADecodingError, RSAKeyFileError, OtherError
}
 This enum type defines error types that are assigned to the QOAuth::Interface::error property. More...
 

Functions

QOAUTH_EXPORT QByteArray supportedOAuthVersion ()
 Returns the supported OAuth protocol version.
 
QOAUTH_EXPORT QByteArray tokenParameterName ()
 Returns the name of the Access Token argument parameter (oauth_token in current implementation) More...
 
QOAUTH_EXPORT QByteArray tokenSecretParameterName ()
 Returns the name of the Token Secret argument parameter (oauth_token_secret in current implementation) More...
 

Enumeration Type Documentation

This error codes collection contains both network-related errors and those that can occur when incorrect arguments are provided to any of the class's methods.

See also
QOAuth::Interface::error
Enumerator
NoError 

No error occured (so far :-) )

BadRequest 

Represents HTTP status code 400 (Bad Request)

Unauthorized 

Represents HTTP status code 401 (Unauthorized)

Forbidden 

Represents HTTP status code 403 (Forbidden)

Timeout 

Represents a request timeout error.

ConsumerKeyEmpty 

Consumer key has not been provided.

ConsumerSecretEmpty 

Consumer secret has not been provided.

UnsupportedHttpMethod 

The HTTP method is not supported by the request.

Note
QOAuth::Interface::requestToken() and QOAuth::Interface::accessToken() accept only HTTP GET and POST requests.
RSAPrivateKeyEmpty 

RSA private key has not been provided.

RSADecodingError 

There was a problem decoding the RSA private key (the key is invalid or the provided passphrase is incorrect)

RSAKeyFileError 

The provided key file either doesn't exist or is unreadable.

OtherError 

A network-related error not specified above.

The HTTP method has to be specified in QOAuth class for two reasons:

Note
For QOAuth::Interface::requestToken() and QOAuth::Interface::accessToken() methods only GET and POST methods are allowed.
Enumerator
GET 

Sets the HTTP method to GET.

POST 

Sets the HTTP method to POST.

HEAD 

Sets the HTTP method to HEAD.

PUT 

Sets the HTTP method to PUT.

DELETE 

Sets the HTTP method to DELETE.

When creating a parameters string for a custom request using QOAuth::Interface::createParametersString() the parsing mode must be defined in order to prepare the string correctly.

According to what is stated in OAuth 1.0 Core specification, parameters can be passed in a request to the Service Provider in 3 different ways. When using QOAuth::Interface::createParametersString(), choose the one that suits you by setting ParsingMode appropriatelly.

See also
QOAuth::Interface::createParametersString()
Enumerator
ParseForRequestContent 

Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests.

ParseForInlineQuery 

Same as ParseForRequestContent, but prepends the string with a question mark - suitable for GET requests (appending parameters to the request URL)

ParseForHeaderArguments 

HTTP request header format (parameters to be put inside a request header)

ParseForSignatureBaseString 

Signature Base String format, meant for internal use.

There are 3 different signature methods defined by the OAuth protocol. This enum is used to specify the method used by a specific request. Hence, one of its values must be passed as a parameter in any of the QOAuth::Interface::requestToken(), QOAuth::Interface::accessToken() or QOAuth::Interface::createParametersString() method.

Enumerator
HMAC_SHA1 

Sets the signature method to HMAC-SHA1.

RSA_SHA1 

Sets the signature method to RSA-SHA1 (not implemented yet)

PLAINTEXT 

Sets the signature method to PLAINTEXT (not implemented yet)

Function Documentation

QByteArray QOAuth::tokenParameterName ( )

Useful when reading Service Provider's reply for QOAuth::Interface::accessToken() request, e.g:

QByteArray requestToken = "token";
QByteArray requestTokenSecret = "secret";
QOAuth::ParamMap reply = qoauth.accessToken( "http://example.com/access_token", QOAuth::POST,
token, tokenSecret, QOAuth::HMAC_SHA1 );
if ( qoauth.error() == QOAuth::NoError ) {
token = reply.value( QOAuth::tokenParameterName() );
tokenSecret = reply.value( QOAuth::tokenSecretParameterName() );
}
QByteArray QOAuth::tokenSecretParameterName ( )