In the authorize then use pattern, a rule is put in place to check if the app is authorized to take a certain action and, if not, do what is necessary to complete the authorization. What makes this work is using the rule postlude to ensure that the rest of the rules (which presumably rely on the authorization) don't run. Here's an example that needs to know Twitter OAuth has happened before the rest of the rules in the ruleset run:
Code Block | ||||
---|---|---|---|---|
| ||||
rule auth |
...
{ select when twitter new_tweet // write so that it's selected for any twitter action if(not twitter:authorized()) then |
...
twitter:authorize() |
...
|
...
|
...
fired {
|
...
last
|
...
}
} |
...
Notice that this rule only fires if the predicate twitter:authorized()
is false. The action, twitter:authorize()
, is what initiates the OAuth ceremony.
...