You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cors.md
+5-33Lines changed: 5 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,43 +23,16 @@ Included in this repository are scripts and source code that hopefully reduce th
23
23
24
24
-[OAuth application registration](../packages/sdk-codegen-scripts/scripts/register.ts) is a Node script that can create and update an OAuth app configuration
25
25
- a sample OAuth application configuration file [`appconfig.json`](../packages/sdk-codegen-scripts/scripts/appconfig.json) has the configuration for the stand-alone [API Explorer](../packages/api-explorer) in this repository
26
-
- a working [`readConfig` override](../packages/run-it/src/utils/RunItSDK.ts) provides the values required by `OAuthSession`
27
-
- a working React-based [OAuth handler](../packages/run-it/src/scenes/OAuthScene) processes OAuth authentications and "logs in" the SDK
26
+
- an [`OAuthConfigProvider`](../packages/extension-utils/src/authUtils.ts) from `@looker/extension-utils` to support OAuth handshakes with the Looker server
28
27
29
28
## SDK support
30
29
31
30
Because the OAuth workflow redirects the browser page to the Looker instance to authenticate, then back to your web application, the Browser's [sessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) is used to persist some variables used by the SDK.
32
31
33
-
### readConfig override
32
+
### OAuth requests
34
33
35
-
`readConfig()` must be overridden to provide the additional configuration values `OAuthSession` needs to complete an OAuth handshake:
36
-
37
-
-`client_id` is the OAuth application ID and **must match the `client_guid` used for the OAuth application registration**.
38
-
-`looker_url` is the url of the Looker application server, typically on port `9999` and **not** the API server, typically on port `19999`.
39
-
-`redirect_uri` is the web application page that receives OAuth responses from the looker server, and **must match the `redirect_uri` used for the OAuth application registration**.
40
-
41
-
The code below is from the [RunIt readConfig() override](../packages/run-it/src/utils/RunItSDK.ts):
To make this code as generic as possible, `looker_url` is based on `base_url` and redirect_uri is calculated from the running web application.
34
+
API Explorer uses a package called "RunIt" to make its API requests. The [`initRunItSDK` function](../packages/run-it/src/utils/RunItSDK.ts) uses the [`OAuthConfigProvider`](../packages/extension-utils/src/authUtils.ts).
35
+
This sets up the authentication session for OAuth.
63
36
64
37
### Automatic login
65
38
@@ -79,7 +52,6 @@ Therefore, `OAuthSession.login()` has three different branches:
79
52
- the `code_verifier` (used for OAuth crypto) is saved to `sessionStorage`
80
53
- the browser session redirects to the Looker server OAuth authentication url
81
54
1. if `returnUrl` is in `sessionStorage`:
82
-
83
55
- the return url is saved locally in `login()` and the `sessionStorage` is cleared
84
56
- the authentication `code` sent by Looker to the `redirect_uri` is used to redeem the Looker authentication code and get an API token.
85
57
-`OAuthSession.activeToken` is assigned this API token
@@ -88,6 +60,6 @@ Therefore, `OAuthSession.login()` has three different branches:
88
60
89
61
Because the OAuth `code` is retrieved from the current browser url, the final `OAuthSession.login()` must be called directly from the `redirect_uri` page.
90
62
91
-
[OAuthScene.tsx](../packages/run-it/src/scenes/OAuthScene/OAuthScene.tsx) shows how the `returnUrl` can be captured and used to go back to the original browser location requiring authentication.
63
+
[OAuthScene.tsx](../packages/extension-utils/src/OAuthScene.tsx) shows how the `returnUrl` can be captured and used to go back to the original browser location requiring authentication.
92
64
93
65
**NOTE**: `OAuthSession.activeToken` is **not** saved in `sessionStorage` so it will disappear if the browser page reloads. That's why `history.push()` is used to relocate the browser page for the React application. The `returnUrl` in `sessionStorage` is a relative URI for this same reason.
Copy file name to clipboardExpand all lines: packages/extension-utils/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# @looker/extension-utils
2
2
3
+
Easier browser-based TypeScript authentication via OAuth, and support for building React applications that can run both inside and outside of [Looker's Extension Framework](https://docs.looker.com/data-modeling/extension-framework/extension-framework-intro) hosting environment.
4
+
3
5
## "Dual mode" Looker browser applications
4
6
5
7
This package provides interfaces and classes that support building a Looker application that can be both hosted as
0 commit comments