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
{{ message }}
This repository was archived by the owner on Aug 5, 2021. It is now read-only.
// This will instantly detect the token and close the page
168
-
newImplicitFlowPopup(clientId);
139
+
```html
140
+
<html><body>
141
+
<h1>Nothing to see here 👻</h1>
142
+
</body></html>
169
143
```
170
144
171
-
Due to the nature of the implicit flow pop-up (referred to as IFP from now on)
172
-
method the callback page can be set to a blank page that just grabs the token
173
-
and then closes. This can be done in the following way.
174
145
175
-
## Password flow (dangerous)
146
+
This will create a pop-up window containing the login page. Once the pop-up redirects back to the callback it will resolve the promise. The callback can be an empty page hosted on the same domain.
176
147
177
-
```js
178
-
var clientId =1; // client id
179
-
var secret =''; // secret
180
-
var username ='[email protected]'; // email is used for authentication
181
-
var password ='Password1!'; // password
182
-
183
-
// Secret will be leaked if this is used on a webpage. Please only use
184
-
// this for non-web applications.
185
-
var auth =newPasswordFlow(clientId, secret, username, password);
186
-
var api =newMaps4News(auth);
187
-
188
-
// This will resolve once the authentication has completed
189
-
api.authenticate().then(function() {
190
-
// Get the current user and dump the result to the console.
191
-
api.users.get('me').then(console.dir);
192
-
});
193
-
```
194
-
195
-
The password flow is **NOT** intended to be used in the browser. If you do
196
-
decide to use the password flow then it is recommended to make sure that
197
-
the site is **NOT** public facing and using HTTPS. Leaking the secret is
198
-
a very bad idea.
148
+
Callback url is set to the current url by default. The script is smart enough close the page if it detects that it's a child after authentication. This means that either the current page can be set as the callback (default) or a blank page. The callback must be hosted on the same domain as the application to allow for cross window communication.
Make sure to store your secret somewhere safe and to only store the token
245
-
and **never** the unencrypted user password.
185
+
These examples assume that an instance of the api exists and is authenticated.
186
+
See the node and web authentication examples for more information on authenticating.
246
187
247
-
## Dummy flow
188
+
The wrapper exposes relations which return proxies. These proxies can be used to either build a route to a resource or to fetch resources. This means that `api.users.get('me')` is the same as calling the route `/v1/users/me`. All proxies expose the methods `new`, `list` and `lister`. Most proxies expose the methods `select` and `get`.
console.log('Found authentication token in cache!');
265
-
}
196
+
consttest=api.static().new(data);
266
197
267
-
api.authenticate().then(function() {
268
-
// Will only resolve if a token was found
269
-
console.log("We're authenticated");
270
-
}).catch(function(err) {
271
-
// This will be called if `api.authenticated` is false
272
-
console.log(err.toString());
273
-
});
198
+
test.fooBarBaz===123;
274
199
```
275
200
276
-
The dummy flow can also be used when a token is known.
201
+
The wrapper will transform snake_case named variables returned from the api into camelCase named variables. This means that for example `place_name` will be transformed into `placeName`.
202
+
203
+
Async methods return a `Promise` this means that both `then/catch` and `await/async` syntax are supported.
277
204
278
-
# Basics
279
-
These examples assume that an instance of the api exists and is authenticated.
280
-
See the node and web authentication examples for more information on authenticating.
Creating a new job and building it is pretty straight foreward. Revisions are slightly different then other resource instances. Their save function requires the new map definition as an argument. This is to make it easier to re-use the same revision instance.
284
+
285
+
340
286
## Pagination
341
287
342
288
> Listing resources with pagination. First page with 5 items per page
0 commit comments