C# Класс Google.GData.Client.OAuthBase

The original OAuth code from http://eran.sandler.co.il/, hosted at http://oauth.net Modified only to change namespace. Written by Eran Sandler (http://eran.sandler.co.il) Edited by Claudio Cherubino and Alain Vongsouvanh
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
OAuth2AccessCode string
OAuth2AccessToken string
OAuth2AccessType string
OAuth2ApprovalPrompt string
OAuth2ClientId string
OAuth2ClientSecret string
OAuth2ExpiresIn string
OAuth2GrantType string
OAuth2RedirectUri string
OAuth2RefreshToken string
OAuth2ResponseType string
OAuth2State string
OAuth2TokenType string
OAuthCallbackKey string
OAuthConsumerKeyKey string
OAuthConsumerSecretKey string
OAuthNonceKey string
OAuthParameterPrefix string
OAuthScopeKey string
OAuthSignatureKey string
OAuthSignatureMethodKey string
OAuthTimestampKey string
OAuthTokenKey string
OAuthTokenSecretKey string
OAuthVerifierKey string
OAuthVersion string
OAuthVersionKey string

Защищенные свойства (Protected)

Свойство Тип Описание
unreservedChars string

Открытые методы

Метод Описание
EncodingPerRFC3986 ( string value ) : string

All parameter names and values are escaped using the [RFC3986] percent-encoding (%xx) mechanism. Characters not in the unreserved character MUST be encoded. Characters in the unreserved character set MUST NOT be encoded. Hexadecimal characters in encodings MUST be upper case. Text names and values MUST be encoded as UTF-8 octets before percent-encoding them per [RFC3629]

GenerateNonce ( ) : string

Generate a nonce

GenerateOAuthSignature ( string consumerSecret, string tokenSecret ) : string

oauth_signature is set to the concatenated encoded values of the Consumer Secret and Token Secret, separated by a ‘&’ character (ASCII code 38), even if either secret is empty. The result MUST be encoded again.

GenerateOAuthSignatureEncoded ( string consumerSecret, string tokenSecret ) : string

oauth_signature is set to the concatenated encoded values of the Consumer Secret and Token Secret, separated by a ‘&’ character (ASCII code 38), even if either secret is empty. This version calls GenerateOAuthSignature and encodes the whole signature again The result MUST be encoded again.

GenerateSignature ( Uri url, string httpMethod, Google.GData.Client.OAuthParameters parameters ) : string

Generates a signature using the specified signatureMethod

GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce ) : string

Generates a signature using the HMAC-SHA1 algorithm

GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureMethod ) : string

Generates a signature using the specified signatureMethod

GenerateSignatureBase ( Uri url, string httpMethod, Google.GData.Client.OAuthParameters parameters ) : string

Generate the signature base that is used to produce the signature

GenerateSignatureBase ( Uri url, string consumerKey, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureType ) : string

Generate the signature base that is used to produce the signature

GenerateSignatureUsingHash ( string signatureBase, HashAlgorithm hash ) : string

Generate the signature value based on the given signature base and hash algorithm

GenerateTimeStamp ( ) : string

Generate the timestamp for the signature

GetExchangeAccessCodeRequestBody ( Google.GData.Client.OAuth2Parameters parameters ) : String

Generate the request body for exchanging an access code for an access token.

GetOAuth2AccessToken ( Google.GData.Client.OAuth2Parameters parameters, String requestBody ) : void

Send the request body to the OAuth 2.0 token endpoint to retrieve an access token. When successful, updates the OAuthParameter instance passed as parameter by setting AccessToken, RefreshToken and TokenExpiry.

GetQueryParameters ( string querystring ) : string>.SortedDictionary

Overloaded version of GetQueryParameters to work without a IDictionary parameter

GetQueryParameters ( string querystring, string>.IDictionary dict ) : string>.SortedDictionary

Internal function to parse query string parameters and merge them with an existing dictionary

GetRefreshAccessTokenRequestBody ( Google.GData.Client.OAuth2Parameters parameters ) : String

Generate the request body for refreshing an access token.

Защищенные методы

Метод Описание
NormalizeRequestParameters ( string>.SortedDictionary parameters ) : string

Normalizes the request parameters according to the spec for the signature generation.

Приватные методы

Метод Описание
ComputeHash ( HashAlgorithm hashAlgorithm, string data ) : string

Helper function to compute a hash value

Описание методов

EncodingPerRFC3986() публичный статический Метод

All parameter names and values are escaped using the [RFC3986] percent-encoding (%xx) mechanism. Characters not in the unreserved character MUST be encoded. Characters in the unreserved character set MUST NOT be encoded. Hexadecimal characters in encodings MUST be upper case. Text names and values MUST be encoded as UTF-8 octets before percent-encoding them per [RFC3629]
public static EncodingPerRFC3986 ( string value ) : string
value string The value to Url encode
Результат string

GenerateNonce() публичный статический Метод

Generate a nonce
public static GenerateNonce ( ) : string
Результат string

GenerateOAuthSignature() публичный статический Метод

oauth_signature is set to the concatenated encoded values of the Consumer Secret and Token Secret, separated by a ‘&’ character (ASCII code 38), even if either secret is empty. The result MUST be encoded again.
public static GenerateOAuthSignature ( string consumerSecret, string tokenSecret ) : string
consumerSecret string
tokenSecret string
Результат string

GenerateOAuthSignatureEncoded() публичный статический Метод

oauth_signature is set to the concatenated encoded values of the Consumer Secret and Token Secret, separated by a ‘&’ character (ASCII code 38), even if either secret is empty. This version calls GenerateOAuthSignature and encodes the whole signature again The result MUST be encoded again.
public static GenerateOAuthSignatureEncoded ( string consumerSecret, string tokenSecret ) : string
consumerSecret string
tokenSecret string
Результат string

GenerateSignature() публичный статический Метод

Generates a signature using the specified signatureMethod
public static GenerateSignature ( Uri url, string httpMethod, Google.GData.Client.OAuthParameters parameters ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
parameters Google.GData.Client.OAuthParameters The OAuth parameters
Результат string

GenerateSignature() публичный статический Метод

Generates a signature using the HMAC-SHA1 algorithm
public static GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
consumerSecret string The consumer seceret
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string The OAuth timestamp. Must be a valid timestamp and equal or greater than /// timestamps used in previous requests
nonce string The OAuth nonce. A random string uniquely generated for each request
Результат string

GenerateSignature() публичный статический Метод

Generates a signature using the specified signatureMethod
public static GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureMethod ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
consumerSecret string The consumer seceret
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string The OAuth timestamp. Must be a valid timestamp and equal or greater than /// timestamps used in previous requests
nonce string The OAuth nonce. A random string uniquely generated for each request
signatureMethod string The type of signature to use
Результат string

GenerateSignatureBase() публичный статический Метод

Generate the signature base that is used to produce the signature
public static GenerateSignatureBase ( Uri url, string httpMethod, Google.GData.Client.OAuthParameters parameters ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
parameters Google.GData.Client.OAuthParameters The OAuth parameters
Результат string

GenerateSignatureBase() публичный статический Метод

Generate the signature base that is used to produce the signature
public static GenerateSignatureBase ( Uri url, string consumerKey, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureType ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string The OAuth timestamp. Must be a valid timestamp and equal or greater than /// timestamps used in previous requests
nonce string The OAuth nonce. A random string uniquely generated for each request
signatureType string The signature type.
Результат string

GenerateSignatureUsingHash() публичный статический Метод

Generate the signature value based on the given signature base and hash algorithm
public static GenerateSignatureUsingHash ( string signatureBase, HashAlgorithm hash ) : string
signatureBase string The signature based as produced by the GenerateSignatureBase method or by any other means
hash System.Security.Cryptography.HashAlgorithm The hash algorithm used to perform the hashing. If the hashing algorithm requires initialization or a key it should be set prior to calling this method
Результат string

GenerateTimeStamp() публичный статический Метод

Generate the timestamp for the signature
public static GenerateTimeStamp ( ) : string
Результат string

GetExchangeAccessCodeRequestBody() публичный статический Метод

Generate the request body for exchanging an access code for an access token.
public static GetExchangeAccessCodeRequestBody ( Google.GData.Client.OAuth2Parameters parameters ) : String
parameters Google.GData.Client.OAuth2Parameters The OAuth 2.0 parameters
Результат String

GetOAuth2AccessToken() публичный статический Метод

Send the request body to the OAuth 2.0 token endpoint to retrieve an access token. When successful, updates the OAuthParameter instance passed as parameter by setting AccessToken, RefreshToken and TokenExpiry.
public static GetOAuth2AccessToken ( Google.GData.Client.OAuth2Parameters parameters, String requestBody ) : void
parameters Google.GData.Client.OAuth2Parameters The OAuth 2.0 parameters
requestBody String The request body to send
Результат void

GetQueryParameters() публичный статический Метод

Overloaded version of GetQueryParameters to work without a IDictionary parameter
public static GetQueryParameters ( string querystring ) : string>.SortedDictionary
querystring string The query string part of the Url
Результат string>.SortedDictionary

GetQueryParameters() публичный статический Метод

Internal function to parse query string parameters and merge them with an existing dictionary
public static GetQueryParameters ( string querystring, string>.IDictionary dict ) : string>.SortedDictionary
querystring string The query string part of the Url
dict string>.IDictionary The dictionary to be merged with the query string parameters
Результат string>.SortedDictionary

GetRefreshAccessTokenRequestBody() публичный статический Метод

Generate the request body for refreshing an access token.
public static GetRefreshAccessTokenRequestBody ( Google.GData.Client.OAuth2Parameters parameters ) : String
parameters Google.GData.Client.OAuth2Parameters The OAuth 2.0 parameters
Результат String

NormalizeRequestParameters() защищенный статический Метод

Normalizes the request parameters according to the spec for the signature generation.
protected static NormalizeRequestParameters ( string>.SortedDictionary parameters ) : string
parameters string>.SortedDictionary The sorted dictionary containing parameters
Результат string

Описание свойств

OAuth2AccessCode публичное статическое свойство

public static string OAuth2AccessCode
Результат string

OAuth2AccessToken публичное статическое свойство

public static string OAuth2AccessToken
Результат string

OAuth2AccessType публичное статическое свойство

public static string OAuth2AccessType
Результат string

OAuth2ApprovalPrompt публичное статическое свойство

public static string OAuth2ApprovalPrompt
Результат string

OAuth2ClientId публичное статическое свойство

public static string OAuth2ClientId
Результат string

OAuth2ClientSecret публичное статическое свойство

public static string OAuth2ClientSecret
Результат string

OAuth2ExpiresIn публичное статическое свойство

public static string OAuth2ExpiresIn
Результат string

OAuth2GrantType публичное статическое свойство

public static string OAuth2GrantType
Результат string

OAuth2RedirectUri публичное статическое свойство

public static string OAuth2RedirectUri
Результат string

OAuth2RefreshToken публичное статическое свойство

public static string OAuth2RefreshToken
Результат string

OAuth2ResponseType публичное статическое свойство

public static string OAuth2ResponseType
Результат string

OAuth2State публичное статическое свойство

public static string OAuth2State
Результат string

OAuth2TokenType публичное статическое свойство

public static string OAuth2TokenType
Результат string

OAuthCallbackKey публичное статическое свойство

public static string OAuthCallbackKey
Результат string

OAuthConsumerKeyKey публичное статическое свойство

public static string OAuthConsumerKeyKey
Результат string

OAuthConsumerSecretKey публичное статическое свойство

public static string OAuthConsumerSecretKey
Результат string

OAuthNonceKey публичное статическое свойство

public static string OAuthNonceKey
Результат string

OAuthParameterPrefix публичное статическое свойство

public static string OAuthParameterPrefix
Результат string

OAuthScopeKey публичное статическое свойство

public static string OAuthScopeKey
Результат string

OAuthSignatureKey публичное статическое свойство

public static string OAuthSignatureKey
Результат string

OAuthSignatureMethodKey публичное статическое свойство

public static string OAuthSignatureMethodKey
Результат string

OAuthTimestampKey публичное статическое свойство

public static string OAuthTimestampKey
Результат string

OAuthTokenKey публичное статическое свойство

public static string OAuthTokenKey
Результат string

OAuthTokenSecretKey публичное статическое свойство

public static string OAuthTokenSecretKey
Результат string

OAuthVerifierKey публичное статическое свойство

public static string OAuthVerifierKey
Результат string

OAuthVersion публичное статическое свойство

public static string OAuthVersion
Результат string

OAuthVersionKey публичное статическое свойство

public static string OAuthVersionKey
Результат string

unreservedChars защищенное статическое свойство

protected static string unreservedChars
Результат string