I’m trying to setup an app to authenticate with Speckle, so the app can make requests to Speckle on the behalf of users.
Currently the documentation on the subject is quite limited: Apps & Auth | Speckle Docs
I have created an app on my profile and gotten an App ID.
However, when I’m redirected to Speckle, the Speckle page throws an error (TypeError: t.app is null) in the console and nothing happens (I’m never redirected back to my page.)
As for your problem, not sure where this would be originating, but I suspect it may have to do with the way you appId variable is being set. Can you confirm that in fact the appId is being set correctly in the url?
I just did a quick test with a new app in speckle.xyz and it the login+redirect worked with no errors and; since this may not be the reason for your error, let me ask you a couple more questions:
What server are you interacting with? Is it our .xyz one? Or do you have your own deployment
Could you send us the url you are being sent to? the appId is public anyway so you can just paste it here in the response. Maybe also a screenshot of what you’re seeing on the login page? Should be something like this
What’s the CANONICAL_URL environment variable for the server container?
I see you access the server via 172.30.* IP address, which is a common subnet for internal docker networks. Is that the docker container IP address, or your computer’s LAN IP address?
yes, I’m running it with Docker-Compose with the required changes. The Speckle runs fine, I have several streams there and the access token systems works.
Are you still having issues? Have you double checked if you use the appId, and not the appSecret (they can be easily confused, as they have the same length)
To test just the server part (without your app involvement), you can just create an app and open the url in your browser:
Follow up question:
I get n access code back, which I exchange for a token pair (access and refresh) as per this
When the access token expires, what endpoint should I hit with the refresh token to get a new access token?
If I loose my refresh token (user logs out or clears browser) do I need to re-authenticate with speckle on {SPECKLE_URL}/authn/verify/{APP_ID}/{NEW_CHALLANGE}?
Hi @chrk! Glad to know you got it working As for your follow up questions:
You can generate a new token from using the refresh token by hitting the same endpoint used to exchange the access code /auth/token with only the refresh token in the body:
{
refreshToken: YOUR_REFRESH_TOKEN
}
as opposed to the body that is passed in to exchange the access code, which looks like this:
The response format does not change, so you don’t need to worry about different ways of handling the response
Yes If you loose your refresh_token you effectively need to re-authenticate again. In the most basic cases (an app that only has speckle login) you may want to actually delete that data, as you don’t really want that lying around for someone else to find.
In more complex cases, such as apps with pre-existing login where what you want is to “link” a Speckle Account to the user, you may want to securely store them in a database so that even if your user logs out of your auth system, you wont have to continue to ask them to re-authorise speckle on their behalf.