Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultAuthorizationRequestMapping map[AuthorizationRequestKey]string = map[AuthorizationRequestKey]string{ AuthorizationRequestClientID: "client_id", AuthorizationRequestRedirectURI: "redirect_uri", AuthorizationRequestScope: "scope", AuthorizationRequestState: "state", } )
View Source
var ( DefaultAuthorizationResponseMapping map[AuthorizationResponseKey]string = map[AuthorizationResponseKey]string{ AuthorizationResponseCode: "code", AuthorizationResponseError: "error", AuthorizationResponseErrorDescription: "error_description", AuthorizationResponseErrorURI: "error_uri", AuthorizationResponseState: "state", } )
View Source
var ( DefaultGrantRequestMapping map[GrantRequestKey]string = map[GrantRequestKey]string{ GrantRequestClientID: "client_id", GrantRequestClientSecret: "client_secret", GrantRequestCode: "code", GrantRequestRedirectURI: "redirect_uri", GrantRequestState: "state", } )
View Source
var ( DefaultGrantResponseMapping map[GrantResponseKey]string = map[GrantResponseKey]string{ GrantResponseAccessToken: "access_token", GrantResponseError: "error", GrantResponseScope: "scope", GrantResponseTokenType: "token_type", } )
Functions ¶
Types ¶
type AuthorizationRequest ¶
type AuthorizationRequest struct { BaseURL string // ClientID is the ID of the client authorizing with the resource owner ClientID string // RedirectURI is the location to redirect to that can receive the authorization response RedirectURI string // Scopes is a list of resource scopes to request for authorization for Scopes []string // ScopeDelimiter is used to concatenate the provided Scopes into a single string ScopeDelimiter string // State is a runtime-generated string to identify this authorization request State string }
func (*AuthorizationRequest) GetURL ¶
func (r *AuthorizationRequest) GetURL(mapping ...map[AuthorizationRequestKey]string) (string, error)
GetURL builds the resource authorization URL for the user
func (*AuthorizationRequest) OpenInBrowser ¶
func (r *AuthorizationRequest) OpenInBrowser(mapping ...map[AuthorizationRequestKey]string) error
OpenInBrowser is a convenience method to open the authorization page in the user's default browser
type AuthorizationRequestKey ¶
type AuthorizationRequestKey string
const ( AuthorizationRequestClientID AuthorizationRequestKey = "authorization_request_client_id_key" AuthorizationRequestRedirectURI AuthorizationRequestKey = "authorization_request_redirect_uri_key" AuthorizationRequestScope AuthorizationRequestKey = "authorization_request_scope_key" AuthorizationRequestState AuthorizationRequestKey = "authorization_request_state_key" DefaultScopeDelimiter = " " )
type AuthorizationResponse ¶
type AuthorizationResponse struct { // Code is the authorization code returned by the authorization // server if the authorization succeeded Code string // Error is an error symbol representing the type of error Error error // ErrorDescription is an arbitrary string describing the error ErrorDescription string // ErrorURI is a URL that can assist a consumer in understanding // the returned ErrorDescription ErrorURI string // State is the unique string sent to the authorization server // for identification of this authorization request State string }
AuthorizationResponse represents the response sent by the authorization server after a user has authorized the application
func (*AuthorizationResponse) LoadFromQuery ¶
func (r *AuthorizationResponse) LoadFromQuery(responseQuery url.Values, mapping ...map[AuthorizationResponseKey]string) error
LoadFromQuery loads this instance of AuthorizationResponse using the URL query values from the callback response
type AuthorizationResponseKey ¶
type AuthorizationResponseKey string
const ( AuthorizationResponseCode AuthorizationResponseKey = "authorization_response_code_key" AuthorizationResponseError AuthorizationResponseKey = "authorization_response_error_key" AuthorizationResponseErrorDescription AuthorizationResponseKey = "authorization_response_error_description_key" AuthorizationResponseErrorURI AuthorizationResponseKey = "authorization_response_error_uri_key" AuthorizationResponseState AuthorizationResponseKey = "authorization_response_state_key" )
type GrantRequest ¶
type GrantRequest struct { // BaseURL defines the URL to query to grant us an access token for the authorization code we possess BaseURL string // ClientID is the ID of the client authorizing with the resource owner ClientID string // ClientSecret is the client secret for exchanging an authorization code for an access token ClientSecret string // COde is the Code string // Method is the HTTP method to use Method string // RedirectURI is the location to redirect to that can receive the authorization response RedirectURI string // State is the unique identifier for the authorization request State string }
func (GrantRequest) Do ¶
func (r GrantRequest) Do(mapping ...map[GrantRequestKey]string) (*GrantResponse, error)
func (GrantRequest) GetRequest ¶
func (r GrantRequest) GetRequest(mapping ...map[GrantRequestKey]string) (*http.Request, error)
type GrantRequestKey ¶
type GrantRequestKey string
const ( GrantRequestClientID GrantRequestKey = "grant_request_client_id_key" GrantRequestClientSecret GrantRequestKey = "grant_request_client_secret_key" GrantRequestCode GrantRequestKey = "grant_request_code_key" GrantRequestRedirectURI GrantRequestKey = "grant_request_redirect_uri_key" GrantRequestState GrantRequestKey = "grant_request_state_key" )
type GrantResponse ¶
GrantResponse represents the response to the request by the application to exchange an authorization code for an access token
func (*GrantResponse) LoadFromJSON ¶
func (r *GrantResponse) LoadFromJSON(responseBody []byte, mapping ...map[GrantResponseKey]string) error
LoadFromJSON parses the provided JSON-formatted responseBody into a GrantResponse instance
type GrantResponseKey ¶
type GrantResponseKey string
const ( GrantResponseAccessToken GrantResponseKey = "grant_response_access_token_key" GrantResponseError GrantResponseKey = "grant_response_error" GrantResponseScope GrantResponseKey = "grant_response_scope_key" GrantResponseTokenType GrantResponseKey = "grant_response_type_key" )
Click to show internal directories.
Click to hide internal directories.