|
1 | | -# frontify-authenticator |
| 1 | +# Frontify Authenticator v2 |
2 | 2 |
|
3 | | -Authenticate to your Frontify instance from within any secure web app |
| 3 | +Authenticate to your Frontify instance from within any secure web app. |
4 | 4 |
|
5 | 5 | # Install |
6 | 6 |
|
7 | | -Installing the latest published package on a 3rd party app is as simple as running `npm i @frontify/frontify-authenticator` and requiring the main class either via CommonJs or as an ES module. |
| 7 | +There are three possible ways of installing or requiring the Frontify Authenticator v2. |
| 8 | + |
| 9 | +## NPM |
| 10 | + |
| 11 | +Installing the latest published package on a third party app is as simple as running `npm i @frontify/frontify-authenticator` and requiring the main class either via CommonJs or as an ES module. |
8 | 12 |
|
9 | 13 | ``` |
10 | 14 | // CommonJs require |
|
15 | 19 |
|
16 | 20 | ``` |
17 | 21 | // ESM import |
18 | | -import FrontifyAuthenticator from '@frontify/frontify-authenticator'; |
| 22 | +import { authorize, refresh, revoke } from '@frontify/frontify-authenticator'; |
19 | 23 | ``` |
20 | 24 |
|
21 | | -There is a require/import example prepared on `src/local.ts` for added convienience simulating an end user import. To try it out, you simply need to run the `npm run local` command on the package root location. |
| 25 | +## CDN |
| 26 | + |
| 27 | +Alternatively, in case you're not relying on npm packages in your web app, you can also require the minified JS script directly by using a CDN such as UPAKG. You can find the latest [Frontify Authenticator v2 source code](https://unpkg.com/@frontify/frontify-authenticator@latest/dist/index.js) and import it to your project you by requiring it via a `<script>` HTML element. |
| 28 | + |
| 29 | +``` |
| 30 | +<script src="https://unpkg.com/@frontify/frontify-authenticator@latest/dist/index.js"></script> |
| 31 | +``` |
| 32 | + |
| 33 | +You may want to require a specific version. To do so you only have to change the word `latest` with the specific version you wish to use (ie. v2.0.0). |
| 34 | + |
| 35 | +To make use of the available methods in the script all you have to do is use the `FrontifyAuthenticator` object reference attached to the `window`. |
| 36 | + |
| 37 | +Example: |
| 38 | + |
| 39 | +``` |
| 40 | +FrontifyAuthenticator.authorize(...); |
| 41 | +``` |
| 42 | + |
| 43 | +or |
| 44 | + |
| 45 | +``` |
| 46 | +window.FrontifyAuthenticator.authorize(...); |
| 47 | +``` |
| 48 | + |
| 49 | +## LOCAL |
| 50 | + |
| 51 | +To install any package locally doesn't differ greatly from the CDN use case. You can use the [link mentioned above](https://unpkg.com/@frontify/frontify-authenticator@latest/dist/index.js) to download the file contents, save it to your local instance and require via `<script>` HTML element making the `src` address point to your local file. |
| 52 | + |
| 53 | +``` |
| 54 | +<script src="<PATH_TO_FILE>/<FILENAME>.js"></script> |
| 55 | +``` |
22 | 56 |
|
23 | | -# Build |
| 57 | +Like mentioned in the CDN case, if may want to require a specific version, all you have to do is change the word `latest` with the specific version you wish to use (ie. v2.0.0). |
24 | 58 |
|
25 | | -To perform a new build simply run `npm run build` in the application root folder. This will regenerate the `dist` folder contents with the production ready typescript compiled files. |
| 59 | +You must be aware that, in this case, the latest code won't be automatically updated so it relies on manual downloads everytime you want to have a new version come into effect within your web app. |
0 commit comments