openhab-core/itests/org.openhab.core.auth.oauth2client.tests
Wouter Born 074bd7a623
Fix BOM dependency issues (#2120)
* Sync biz.aQute.tester.junit-platform version using bnd.version property
* Remove duplicate osgi-resource-locator dependency, causing warnings/unstability

Signed-off-by: Wouter Born <github@maindrain.net>
2021-01-15 16:33:39 +01:00
..
src/main/java/org/openhab/core/auth/oauth2client/test/internal Update license headers to 2021 (#2041) 2021-01-01 16:43:46 +01:00
.classpath [infrastructure] add external null-annotations (#1775) 2020-11-03 21:33:48 +01:00
.project add some tests and prepare infrastructure (#531) 2019-02-05 09:32:49 +01:00
itest.bndrun Fix BOM dependency issues (#2120) 2021-01-15 16:33:39 +01:00
NOTICE Updated NOTICE files to openHAB (#578) 2019-02-15 10:46:18 +01:00
pom.xml Apply Spotless, resolve itest runbundles for 3.1.0 (#1982) 2020-12-22 10:01:42 +01:00
README.md Use "openhab" console scope (#1586) 2020-08-11 20:38:24 +02:00

This is a working bundle for demonstrating/ testing the OAuth2 client. Passwords, secrets, etc have to be configured through config admin in order for it to work

Simply deploy it to the runtime; then openhab:oauth commands will be registered and ready to test.

Example 1: (Using authorization code)

Try these on the OSGI console:

openhab:oauth Code cleanupEverything
openhab:oauth Code create
openhab:oauth Code getClient <fill in handle from create step>
openhab:oauth Code getAuthorizationUrl
now open browser with the URL from above step, authenticate yourself
to a real oauth provider
if everything works properly, it should redirect you to your redirectURL
Read the code http parameter from the redirectURL
openhab:oauth Code getAccessTokenByCode <code from redirectURL parameter>
openhab:oauth Code getCachedAccessToken
openhab:oauth Code refresh
openhab:oauth Code close

Example 2: (Using ResourceOwner credentials i.e. you have the user's username and password directly)

Try these on the OSGI console:

openhab:oauth ResourceOwner create
openhab:oauth ResourceOwner getClient <fill in handle from create step>
openhab:oauth ResourceOwner getAccessTokenByResourceOwnerPassword
openhab:oauth ResourceOwner getCachedAccessToken
openhab:oauth ResourceOwner refresh
openhab:oauth ResourceOwner close

load again, similar to reboot/restart

openhab:oauth ResourceOwner getClient <fill in handle from create step>
openhab:oauth ResourceOwner getCachedAccessToken
openhab:oauth ResourceOwner refresh

Done playing, delete this service permanently

openhab:oauth ResourceOwner delete <fill in handle from create step>

Verify this is deleted (will throw exception)

openhab:oauth ResourceOwner getCachedAccessToken 

Cannot get the client after delete

openhab:oauth ResourceOwner getClient <fill in handle from create step>