In this example (GitHub - tjvantoll/notecard-ack-example: An example web application showing how to do acknowledgments for Notecard- and Notehub-based projects · GitHub) a Notehub API Key is required. I tried to use this command: curl -X GET -L ‘https://api.notefile.net/v1/projects//devices//public-key’ -H ‘Authorization: Bearer <access_token>’
I have generated a token “api_key_xxxx..” and introduced in <access_token>. However, it doesn’t work. I get this message:
{“err”:“anonymous users cannot use the API. please provide an authentication token”,“code”:401,“status”:“Unauthorized”,“details”:{“transaction_id”:“b7b9604f5e279ac5”}}
Can someone explain how to get an API key then?
Thanks
Hi @carlosG,
The recommended way to create an API key is via Personal Access Tokens. I would follow those guides in order to access the Notehub APIs.
Thanks,
Rob
@carlosG And thanks for pointing this out!
This example predated our introduction of Personal Access Tokens, and I forgot to update the web app. It should be good to go now. Here’s the relevant update: notecard-ack-example/webapp/app/page.tsx at 4af4f61ba34e9c68939c9f7787cbf2ad44c39c97 · tjvantoll/notecard-ack-example · GitHub.
Thanks!
TJ
Thanks @tjvantoll , I think some integrations are failing since the introduction of the PATs. For example, the integration with Blynk. The tutorial is outdated and the Blynk console is requiring “ClientID” and “Client Secret” to be obtained from Notehub Programmatic API access, which is not on Notehub anymore.
Routing Data to Cloud - IoT Connectivity at Blues
So, can you please indicate what credentials are now needed for integration with Blynk?
many thanks,
Carlos
Another issue: In the notecard-ack-example, with the PAT, APP_UID and Device_UID placed in a .env file, I get this error from the browser:
[browser] Uncaught TypeError: Cannot set properties of undefined (setting ‘accessToken’)
at Home (app/page.tsx:26:19)
Thanks,
Carlos
I think some integrations are failing since the introduction of the PATs. For example, the integration with Blynk. The tutorial is outdated and the Blynk console is requiring “ClientID” and “Client Secret” to be obtained from Notehub Programmatic API access, which is not on Notehub anymore.
Routing Data to Cloud - IoT Connectivity at Blues
So, can you please indicate what credentials are now needed for integration with Blynk?
Ah, thanks for letting us know. You do need the same credentials, but the section they’re in is now named “OAuth” Notehub API Introduction - IoT Connectivity at Blues .
I’ll update the tutorial this week.
Another issue: In the notecard-ack-example, with the PAT, APP_UID and Device_UID placed in a .env file, I get this error from the browser:
[browser] Uncaught TypeError: Cannot set properties of undefined (setting ‘accessToken’)
at Home (app/page.tsx:26:19)
Make sure you have a .env file in the webapp folder with the following variables defined notecard-ack-example/webapp at main · tjvantoll/notecard-ack-example · GitHub .
I just ran the project locally and I found a few small issues that I also pushed, so you’ll want to pull down those changes as well.
Thanks for taking the time to let us know about these issues. If you hit any other problems let me know.
TJ
Thanks @tjvantoll. I had a typo in one of the variables. So, that part is solved. The problem I am facing now is related to installing the dependencies. When running ‘npm install’ and ‘npm install --force’ there are 2 moderate severity vulnerabilities remaining. The server cannot run due to several [browser] Uncaught Error: [object Object].
I am planning to create a clean next app and add progressively your code to it.
Thanks,
Carlos
I have now re-built the next app from scratch. The issue is when running eventApiInstance.getEvents().then().catch()
The browser gives a long list of errors, like:
[browser] Uncaught Error: [object Object]
at coerceError (file://C:/Users/… /blues-app/.next/dev/static/chunks/node_modules_next_dist_115brz8..js:2275:73)
at Object.decorateDevError (file://…/blues-app/.next/dev/static/chunks/node_modules_next_dist_115brz8..js:2294:19)
The Swan on Notecarrier-F is conected to Notehub. The .env file is located at the same folder as page.tsx and contains the right credentials.
Thanks,
Carlos
Hey @carlosG,
The .env file is located at the same folder as page.tsx and contains the right credentials.
The .env should be in the root of the Next project. (In the same folder as the package.json file.)
That should explain the issue you’re having with the browser errors. I’m not really sure what’s causing your npm issues though, unfortunately. I do like the idea of just starting a new project and copying changes over though—basically all of the relevant logic is in page.tsx.
TJ