// // disable StyleCop on this file
//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
///
/// An enumeration of the OAuth protocol versions supported by this library.
///
public enum ProtocolVersion {
///
/// The OAuth 2.0 specification.
///
V20,
}
///
/// Protocol constants for OAuth 2.0.
///
internal class Protocol {
///
/// The HTTP authorization scheme "Bearer";
///
internal const string BearerHttpAuthorizationScheme = "Bearer";
///
/// The HTTP authorization scheme "Bearer ";
///
internal const string BearerHttpAuthorizationSchemeWithTrailingSpace = BearerHttpAuthorizationScheme + " ";
///
/// The format of the HTTP Authorization header value that authorizes OAuth 2.0 requests using bearer access tokens.
///
internal const string BearerHttpAuthorizationHeaderFormat = BearerHttpAuthorizationSchemeWithTrailingSpace + "{0}";
///
/// The name of the parameter whose value is an OAuth 2.0 bearer access token, as it is defined
/// in a URL-encoded POST entity or URL query string.
///
internal const string BearerTokenEncodedUrlParameterName = "access_token";
///
/// The "type" string.
///
internal const string type = "type";
///
/// The "state" string.
///
internal const string state = "state";
///
/// The "redirect_uri_mismatch" string.
///
internal const string redirect_uri_mismatch = "redirect_uri_mismatch";
///
/// The "bad_verification_code" string.
///
internal const string bad_verification_code = "bad_verification_code";
///
/// The "incorrect_client_credentials" string.
///
internal const string incorrect_client_credentials = "incorrect_client_credentials";
///
/// The "unauthorized_client" string.
///
internal const string unauthorized_client = "unauthorized_client";
///
/// The "authorization_expired" string.
///
internal const string authorization_expired = "authorization_expired";
///
/// The "redirect_uri" string.
///
internal const string redirect_uri = "redirect_uri";
///
/// The "client_id" string.
///
internal const string client_id = "client_id";
///
/// The "scope" string.
///
internal const string scope = "scope";
///
/// The "immediate" string.
///
internal const string immediate = "immediate";
///
/// The "client_secret" string.
///
internal const string client_secret = "client_secret";
///
/// The "code" string.
///
internal const string code = "code";
///
/// The "user_code" string.
///
internal const string user_code = "user_code";
///
/// The "verification_uri" string.
///
internal const string verification_uri = "verification_uri";
///
/// The "interval" string.
///
internal const string interval = "interval";
///
/// The "error" string.
///
internal const string error = "error";
///
/// The "access_token" string.
///
internal const string access_token = "access_token";
///
/// The "access_token_secret" string.
///
internal const string access_token_secret = "access_token_secret";
///
/// The "token_type" string.
///
internal const string token_type = "token_type";
///
/// The "refresh_token" string.
///
internal const string refresh_token = "refresh_token";
///
/// The "expires_in" string.
///
internal const string expires_in = "expires_in";
///
/// The "expired_delegation_code" string.
///
internal const string expired_delegation_code = "expired_delegation_code";
///
/// The "username" string.
///
internal const string username = "username";
///
/// The "password" string.
///
internal const string password = "password";
///
/// The "format" string.
///
internal const string format = "format";
///
/// The "assertion" string.
///
internal const string assertion = "assertion";
///
/// The "assertion_type" string.
///
internal const string assertion_type = "assertion_type";
///
/// The "user_denied" string.
///
internal const string user_denied = "user_denied";
///
/// Gets the instance with values initialized for V1.0 of the protocol.
///
internal static readonly Protocol V20 = new Protocol {
Version = new Version(2, 0),
ProtocolVersion = ProtocolVersion.V20,
};
///
/// A list of all supported OAuth versions, in order starting from newest version.
///
internal static readonly List AllVersions = new List() { V20 };
///
/// The default (or most recent) supported version of the OpenID protocol.
///
internal static readonly Protocol Default = AllVersions[0];
///
/// The "error_uri" string.
///
public const string error_uri = "error_uri";
///
/// The "error_description" string.
///
internal const string error_description = "error_description";
///
/// The "response_type" string.
///
internal const string response_type = "response_type";
///
/// The "grant_type" string.
///
internal const string grant_type = "grant_type";
///
/// Gets or sets the OAuth 2.0 version represented by this instance.
///
/// The version.
internal Version Version { get; private set; }
///
/// Gets or sets the OAuth 2.0 version represented by this instance.
///
/// The protocol version.
internal ProtocolVersion ProtocolVersion { get; private set; }
///
/// Gets the OAuth Protocol instance to use for the given version.
///
/// The OAuth version to get.
/// A matching instance.
public static Protocol Lookup(ProtocolVersion version) {
switch (version) {
case ProtocolVersion.V20: return Protocol.V20;
default: throw new ArgumentOutOfRangeException("version");
}
}
///
/// Values for the "response_type" parameter.
///
internal static class ResponseTypes
{
///
/// The string "code".
///
internal const string Code = "code";
///
/// The string "token".
///
internal const string Token = "token";
}
internal static class GrantTypes
{
internal const string AuthorizationCode = "authorization_code";
internal const string Password = "password";
internal const string Assertion = "assertion";
internal const string RefreshToken = "refresh_token";
internal const string ClientCredentials = "client_credentials";
}
///
/// Error codes that an authorization server can return to a client in response to a malformed or unsupported access token request.
///
internal static class AccessTokenRequestErrorCodes
{
///
/// The request is missing a required parameter, includes an unknown parameter or parameter value, repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.
///
internal const string InvalidRequest = "invalid_request";
///
/// The client is not authorized to use the access grant type provided.
///
internal const string UnauthorizedClient = "unauthorized_client";
///
/// The resource owner or authorization server denied the request.
///
internal const string AccessDenied = "access_denied";
///
/// The authorization server does not support obtaining an access token using this method.
///
internal const string UnsupportedGrantType = "unsupported_response_type";
///
/// The requested scope is invalid, unknown, malformed, or exceeds the previously granted scope.
///
internal const string InvalidScope = "invalid_scope";
}
///
/// Error codes that an authorization server can return to a client in response to a malformed or unsupported end user authorization request.
///
internal static class EndUserAuthorizationRequestErrorCodes
{
///
/// The request is missing a required parameter, includes an unknown parameter or parameter value, or is otherwise malformed.
///
internal const string InvalidRequest = "invalid_request";
///
/// The client is not authorized to use the requested response type.
///
internal const string UnauthorizedClient = "unauthorized_client";
///
/// The end-user or authorization server denied the request.
///
internal const string AccessDenied = "access_denied";
///
/// The requested response type is not supported by the authorization server.
///
internal const string UnsupportedResponseType = "unsupported_response_type";
///
/// The requested scope is invalid, unknown, or malformed.
///
internal const string InvalidScope = "invalid_scope";
}
///
/// Recognized access token types.
///
internal static class AccessTokenTypes {
///
/// The "bearer" token type.
///
internal const string Bearer = "bearer";
}
}
}