anchor.diff:                           | oauth1_random_string:error()
                            )
       ).
  +
  +-record(common_sig_params,
  +    { method               :: oauth1_signature:method()
  +    , http_req_method      :: binary()
  +    , http_req_host        :: binary()
  +    , resource             :: oauth1_resource:t()
  +    , consumer_key         :: oauth1_credentials:id(client)
  +    , timestamp            :: oauth1_timestamp:t()
  +    , nonce                :: oauth1_nonce:t()
  +    , callback      = none :: hope_option:t(oauth1_uri:t())
  +    }).
  +
  +-type common_sig_params() ::
  +    #common_sig_params{}.
   
   
   %% @doc Generate and store a credentials pair {ClientID, ClientSecret).
  
positive.code:     , host                = Host
      }
  ) ->
      ValidateSignature =
          fun (#request_validation_state
              { given_creds_client = {some, ClientCredentials}
              }=State) ->
              ClientSharedSecret =
                  oauth1_credentials:get_secret(ClientCredentials),
              SigArgs =
                  #oauth1_signature_args_cons
                  { method               = SigMethod
                  , http_req_method      = <<"POST">>
                  , http_req_host        = Host
                  , resource             = Resource
                  , consumer_key         = ConsumerKey
                  , timestamp            = Timestamp
                  , nonce                = Nonce
  
                  , client_shared_secret = ClientSharedSecret
  
                  , token                = none
                  , verifier             = none
                  , callback             = {some, CallbackURI}
                  },
              SigComputed       = oauth1_signature:cons(SigArgs),
              SigComputedDigest = oauth1_signature:get_digest(SigComputed),
              case SigGiven =:= SigComputedDigest
              of  false -> {error, {unauthorized, signature_invalid}}
              ;   true  -> {ok, State}
              end
          end,
      Steps =
          [ make_validate_consumer_key(ConsumerKey)
          , ValidateSignature
          , make_validate_nonce(Nonce)
          , make_issue_token(tmp)
          , fun (#request_validation_state{issued_creds_tmp={some, Token}}) ->
  
negative.code:     , host             = Host
      }
  ) ->
      CommonSigParams = #common_sig_params
          { method          = SigMethod
          , http_req_method = <<"POST">>
          , http_req_host   = Host
          , resource        = Resource
          , consumer_key    = ConsumerKey
          , timestamp       = Timestamp
          , nonce           = Nonce
          , callback        = none
          },
      Steps =
          [ make_validate_consumer_key(ConsumerKey)
          , make_validate_token_exists(TmpTokenID)
          , make_validate_verifier(VerifierGivenBin, TmpTokenID)
          , make_validate_signature(SigGiven, {some, tmp}, CommonSigParams)
          , make_validate_nonce(Nonce)
          , make_issue_token(token)
          ],
  