1 Common Definitions
This section describes the common constants, structs, and exceptions across both the client and server implementations.
1.1 Module oauth2.
(require oauth2) | package: simple-oauth2 |
value
OAUTH-SPEC-VERSION : number? = 2.0
value
OAUTH-RFC : exact-positive-integer? = 6749
value
OAUTH-DISPLAY-NAME : string? = "OAuth {{version}} (RCF{{rfc}})"
value
syntax
(log-oauth2-debug string-expr)
(log-oauth2-debug format-string-expr v ...)
syntax
(log-oauth2-info string-expr)
(log-oauth2-info format-string-expr v ...)
syntax
(log-oauth2-warning string-expr)
(log-oauth2-warning format-string-expr v ...)
syntax
(log-oauth2-error string-expr)
(log-oauth2-error format-string-expr v ...)
syntax
(log-oauth2-fatal string-expr)
(log-oauth2-fatal format-string-expr v ...)
1.1.1 Structure Types
struct
(struct client ( service-name authorization-uri token-uri revoke-uri introspect-uri id secret) #:extra-constructor-name make-client #:prefab) service-name : string? authorization-uri : string? token-uri : string? revoke-uri : (or/c string? #f) introspect-uri : (or/c string? #f) id : (or/c string? #f) secret : (or/c bytes? #f)
The id and secret are the values provided by the service to you, the client, for authentication. The client id should uniquely identify your client and the secret is used in certain token grant flows. Note that the secret value should always be stored securely, see Module oauth2/storage/clients. for details on persistence of client details.
The revoke-uri and introspect-uri fields are both optional as it may be that the service does not support revoking or introspecting tokens.
struct
(struct token ( access-token type refresh-token audience scopes expires) #:extra-constructor-name make-token #:prefab) access-token : bytes? type : string? refresh-token : bytes? audience : (or/c string? #f) scopes : (listof string?) expires : exact-positive-integer?
The value of expires denotes the time, in seconds, at which the access-token will expire and no longer be valid for use. This is stored as an absolute value so that the is expired? test is simply:
(define (token-expired? t) (> (current-seconds) (token-expires t)))
Note that the access-token and refresh-token values should always be stored securely, see Module oauth2/storage/tokens. for details on persistence of token details.
1.1.2 Exceptions
struct
(struct exn:fail:http exn:fail (code headers body) #:extra-constructor-name make-exn:fail:http #:transparent) code : integer? headers : list? body : bytes?
struct
(struct exn:fail:oauth2 exn:fail (error error-uri state) #:extra-constructor-name make-exn:fail:oauth2 #:transparent) error : symbol? error-uri : (or/c string? #f) state : (or/c string? #f)
procedure
exn : exn:fail:oauth2?