dev/core#2141 - Add support for token-tagging to all grant flows
authorTim Otten <totten@civicrm.org>
Fri, 30 Oct 2020 00:58:01 +0000 (17:58 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 3 Nov 2020 12:32:48 +0000 (04:32 -0800)
commit9cde63e81a9926a1c54786b0d28dc55fffd8a1b6
tree68c2a20589c78fbebdd8b265c858a2af7f3f13a2
parent3d13e544f00199ebab98e5fe1dee92b6441b5167
dev/core#2141 - Add support for token-tagging to all grant flows

Suppose you have a downstream app/module -- such as the Civi-IMAP app/module.  It needs to store a notation which says
"this thing in our data" (e.g.  `civicrm_mail_settings`) "corresponds to that token in the OAuth data".

It can put a tag on the token (`tag=civicrm_mail_settings:123`) and use that for lookup

```
$tag = `OAuthSysToken.refresh +w tag=civicrm_mail_settings:123`
```

The advantage of this is that it's simple, flexible, and doesn't require new schema.

Of course, it's not end-all/be-all.  It's OK for 1:1 relationship.  But if
you want 1:M or M:M, then you'll have to model that as something else.  But
for basic usage, tags are simple and moderately flexible.
ext/oauth-client/CRM/OAuth/BAO/OAuthSysToken.php
ext/oauth-client/CRM/OAuth/Page/Return.php
ext/oauth-client/Civi/Api4/Action/OAuthClient/AbstractGrantAction.php
ext/oauth-client/Civi/Api4/Action/OAuthClient/AuthorizationCode.php
ext/oauth-client/Civi/Api4/Action/OAuthClient/ClientCredential.php
ext/oauth-client/Civi/Api4/Action/OAuthClient/UserPassword.php
ext/oauth-client/Civi/OAuth/OAuthTokenFacade.php