2020-08-11 20:38:24 +02:00
|
|
|
This is a working bundle for demonstrating/ testing the OAuth2 client.
|
2019-01-28 13:07:31 +01:00
|
|
|
Passwords, secrets, etc have to be configured through config admin in order for it to work
|
|
|
|
|
2020-08-11 20:38:24 +02:00
|
|
|
Simply deploy it to the runtime; then openhab:oauth commands will be registered and ready to test.
|
2019-01-28 13:07:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Example 1: (Using authorization code)
|
|
|
|
|
|
|
|
## Try these on the OSGI console:
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth Code cleanupEverything
|
|
|
|
openhab:oauth Code create
|
|
|
|
openhab:oauth Code getClient <fill in handle from create step>
|
|
|
|
openhab:oauth Code getAuthorizationUrl
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth Code getAccessTokenByCode <code from redirectURL parameter>
|
|
|
|
openhab:oauth Code getCachedAccessToken
|
|
|
|
openhab:oauth Code refresh
|
|
|
|
openhab:oauth Code close
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
# Example 2: (Using ResourceOwner credentials i.e. you have the user's username and password directly)
|
|
|
|
|
|
|
|
## Try these on the OSGI console:
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
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
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### load again, similar to reboot/restart
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth ResourceOwner getClient <fill in handle from create step>
|
|
|
|
openhab:oauth ResourceOwner getCachedAccessToken
|
|
|
|
openhab:oauth ResourceOwner refresh
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Done playing, delete this service permanently
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth ResourceOwner delete <fill in handle from create step>
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Verify this is deleted (will throw exception)
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth ResourceOwner getCachedAccessToken
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Cannot get the client after delete
|
|
|
|
|
|
|
|
```
|
2020-08-11 20:38:24 +02:00
|
|
|
openhab:oauth ResourceOwner getClient <fill in handle from create step>
|
2019-01-28 13:07:31 +01:00
|
|
|
```
|