@@ -11,6 +11,7 @@ To use Header simply embed the ws-header in your application and import the scss
11
11
``` html
12
12
<ws-header
13
13
appName =" Demo Page"
14
+ businessPartnerId =" business-partner-id"
14
15
clientId =" youturn-client-id"
15
16
links =" {[
16
17
{label: 'Link', href: 'LinkValue', onClick: (value) => console.log(value)},
@@ -59,11 +60,9 @@ you have to listen for the `ws-locale-changed` event on the window object.
59
60
## Authorization
60
61
Every user must retrieve an access token via the OAuth2 Implicit flow to get access to the backend resources.
61
62
The header already implements these implicit flow and a login button. To be able to authenticate with the
62
- implicit flow you have to specify you're client id. The other required fields are filled with the following defaults.
63
- - ** loginUrl** : https://identity.zalando.com/oauth2/authorize
64
- - ** businessPartnerId** : zalando's business partner id
63
+ implicit flow you have to specify you're client and business partner id. The default login url is: https://identity.zalando.com/oauth2/authorize
65
64
``` html
66
- <ws-header app-name =" Test app" client-id =" yourturn-client-id" ></ws-header >
65
+ <ws-header app-name =" Test app" client-id =" yourturn-client-id" business-partner-id = " bpid " ></ws-header >
67
66
```
68
67
69
68
##### Getting the access token
@@ -79,12 +78,10 @@ if the access_token was successfully parsed from the location.hash. It can be em
79
78
```
80
79
81
80
To get the access token for example to validate if the user can access the current route you can call
82
- the static function ` getAccessToken() ` which will return a promise with the access token or null.
81
+ the static function ` getAccessToken() ` which will return the access token or null.
83
82
``` html
84
83
<script >
85
- WSHeader .getAccessToken ().then (accessToken => {
86
- console .log (' Current access token is: ' , accessToken);
87
- })
84
+ console .log (' Current access token is: ' , WSHeader .getAccessToken ());
88
85
</script >
89
86
```
90
87
@@ -103,12 +100,3 @@ listening for those events and triggers the corresponding action. Afterwards a `
103
100
window .dispatchEvent (new CustomEvent (' ws-unauthorize' ));
104
101
</script >
105
102
```
106
-
107
- ##### Refresh tokens (experimental)
108
- Since the refresh token URL of Zalando don't permit cross origin access you have to provide a
109
- proxy solution by yourself and specify the url as attribute. The proxy url should point to
110
- ` https://identity.zalando.com/oauth2/token ` . The header automatically will request a new access token
111
- once the expiration time of the last one was reached and a ` ws-auth-changed ` event will be published.
112
- ``` html
113
- <ws-header app-name =" Test app" client-id =" yourturn-client-id" refresh-url =" /backend/identity/refresh" ></ws-header >
114
- ```
0 commit comments