java.lang.RuntimeException: Metadata Error: Missing required page parameter 'name'

I’m trying to follow the SmartApp Authentication guide but the code that is provided in the examples hits this error:

java.lang.RuntimeException: Metadata Error: Missing required page parameter 'name' @ line 42

Here is the code I have:

mappings {
    path("/oauth/initialize") {action: [GET: "oauthInitUrl"]}
    path("/oauth/callback") {action: [GET: "callback"]}
}

preferences {
    page(name: "Credentials", title: "Sample Authentication", content: "authPage", nextPage: "sampleLoggedInPage", install: false)
}

def authPage() {
    if(!state.accessToken) {
        createAccessToken()
    }
    def redirectUrl = "https://graph.api.smartthings.com/oauth/initialize?appId=${app.id}&access_token=${state.accessToken}&apiServerUrl=${getApiServerUrl()}"
    if(!state.authToken) {
        return dynamicPage(name: "auth", title: "Login", nextPage: "", uninstall: false) {
            section() {
                paragraph "tap below to log in to the 3rd party service and authorize SmartThings access"
                href url: redirectUrl, style: "embedded", required: true, title: "3rd Party product", description: "Click to enter credentials"
            }
        }
    } 
}

This error message is super confusing given that every page I’ve defined does already have a name parameter specified. Could the error message be a red herring? Being new to this and just going through the initial guides, I can’t say I understand enough about the ecosystem to know what else could be wrong with the sample code (you would expect that if you copy+paste the code from the official documentation, it would work!).

Does your SmartApp have the required metadata at the top of the file?

definition(
name: β€œβ€,
namespace: β€œβ€,
author: β€œβ€,
description: β€œβ€,
category: β€œβ€,
iconUrl: β€œβ€)

It does, though I omitted that in my original post.

Has anything been solved on this? I’m developing a DTH with the same issue occuring.

I think you have to add the line below to the preferences section below the other page declaration.

page(name: "auth")

1 Like