The access token is part of OAuth, so they're tied. But you also need to define "mappings" so your app knows what the parts of the URL means (the Maker API, apparently, mapped /devices
to something in its code).
Fair warning: what you want to do is not super-easy if you are new to the platform. Hubitat's developer docs are a bit lacking (and to be fair, they bill themselves as open but not a development platform). The docs for SmartThings are pretty close in most regards, mostly including this, but besides URL differences for cloud, Hubitat also has local endpoints. This thread has a bit more specifically on this: Oauth Flow Cloud and Local
Here's a basic app that serves a simple HTML page (JSON would be even easier!) and gives you the link to do so from the app. It's not super-complete, and note that you have to fully install the app (click "Done" then go back in) before it will actually work, but hopefully it shows you the basics of how it can be done:
// Example OAuth app for Hubitat
definition (
name: "Example OAuth App",
namespace: "Example",
author: "Author",
description: "Example of local and cloud OAuth links/mappings",
category: "Convenience",
iconUrl: "",
iconX2Url: "",
iconX3Url: ""
)
preferences {
page(name: "myPage", uninstall: true, install: true) {
section("Links") {
paragraph("<a href=\"${getUrl('myFirstMapping')}\">Local LAN link to myFirstMapping</a>")
paragraph("<a href=\"${getUrl('myFirstMapping', false)}\">Cloud chart link to myFirstMapping</a>")
}
}
}
def installed() {
log.info("Installed with settings: ${settings}")
initialize()
}
def uninstalled() {
log.info("Uninstalling")
}
def updated() {
log.info("Updated with settings: ${settings}")
initialize()
}
def initialize() {
log.debug("Initializing...")
initEndpoint()
}
private initEndpoint() {
if (!state.accessToken) {
try {
def accessToken = createAccessToken()
if (accessToken) {
state.accessToken = accessToken
}
}
catch(e) {
state.accessToken = null
}
}
return state.accessToken
}
private getUrl(path, local=true) {
def url = (local ? "${getFullLocalApiServerUrl()}/$path?access_token=${state.accessToken}" :
"${getFullApiServerUrl()}/$path?access_token=${state.accessToken}")
return url
}
mappings {
path("/myFirstMapping") {action: [GET: "myHTMLEndpoint"]}
}
def myHTMLEndpoint() {
render(contentType: "text/html", data:
"""<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>My Page</h1>
<p>My Text</p>
</body>
</html>"""
)
}
EDIT: While I was writing this, I see you made more progress. My assumption above is that you are trying to write a custom app. If you are trying to integrate with something else, several built-in or existing community options can help (e.g., MakerAPI provides endpoints you can do a lot with) without you needing to write a custom app on the Hubitat side.