diff --git a/examples/auth-generate-token/javascript/.gitignore b/examples/auth-generate-token/javascript/.gitignore new file mode 100644 index 0000000000..fd3dbb571a --- /dev/null +++ b/examples/auth-generate-token/javascript/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/examples/auth-generate-token/javascript/README.md b/examples/auth-generate-token/javascript/README.md new file mode 100644 index 0000000000..51ec023a8e --- /dev/null +++ b/examples/auth-generate-token/javascript/README.md @@ -0,0 +1,57 @@ +# Generate an Ably token to authenticate clients + +This folder contains the code for the authentication (Typescript) - a demo of how you can authenticate with [Ably](https://ably.com/docs/auth) to use any of the products. + +## Getting started + +1. Clone the [Ably docs](https://github.com/ably/docs) repository where this example can be found: + +```sh +git clone git@github.com:ably/docs.git +``` + +2. Change directory: + +```sh +cd /examples/auth-generate-token/javascript/ +``` + +3. Install dependencies: + +```sh +yarn install +``` + +4. Run the frontend client: + +```sh +yarn run dev +``` + +5. In a new tab, change directory: + +```sh +cd /examples/auth-generate-token/server/ +``` + +6. Rename the environment file: + +```sh +mv .env.example .env.local +``` + +7. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key. + +8. Install dependencies: + +```sh +yarn install +``` + +9. Run the backend server: + +```sh +yarn run dev +``` + +10. Try it out by opening two tabs to [http://localhost:5173/](http://localhost:5173/) with your browser to see the result. diff --git a/examples/auth-generate-token/javascript/index.html b/examples/auth-generate-token/javascript/index.html new file mode 100644 index 0000000000..38ece301ef --- /dev/null +++ b/examples/auth-generate-token/javascript/index.html @@ -0,0 +1,48 @@ + + +
+ + + + ++ Press the Connect button to initialize the client: +
+ +The Ably client has been successfully initialized.
+Press the Connect button to initialize the client:
+ +