@@ -26,23 +26,34 @@ import Strapi from 'strapi-sdk-javascript';
2626const strapi = new Strapi (' http://localhost:1337' );
2727
2828(async () => {
29+ // Local authentication
2930 await strapi .login (' username_or_email' , ' s3cr3t' );
31+
32+ // Or within provider
33+ window .location = strapi .getProviderAuthenticationUrl (' facebook' )
34+ // ...
35+ // Once authorized, Facebook redirects the user to your app with an access token in the URL.
36+ // Complete the authentication: (The SDK will handle the access token for you)
37+ await strapi .authenticateProvider (' facebook' )
38+
39+ // You can now fetch private APIs
3040 const posts = await strapi .getEntries (' post' );
3141 console .log (` Posts count: ${ posts .length } ` );
3242})();
3343```
3444
3545## API
3646
37- ### ` Strapi(baseURL, requestConfig) `
47+ ### ` Strapi(baseURL, storeConfig, requestConfig) `
3848### ` request(method, url, requestConfig) `
3949### ` register(username, email, password) `
4050### ` login(identifier, password) `
4151### ` forgotPassword(email, url) `
4252### ` resetPassword(code, password, passwordConfirmation) `
4353### ` getProviderAuthenticationUrl(provider) `
4454### ` authenticateProvider(provider, params) `
45- ### ` setToken(token) `
55+ ### ` setToken(token, comesFromStorage) `
56+ ### ` clearToken(token) `
4657### ` getEntries(contentType, params) `
4758### ` getEntry(contentType, id) `
4859### ` createEntry(contentType, data) `
@@ -65,7 +76,6 @@ Custom axios request configuration. [See documentation](https://github.com/axios
6576## Roadmap
6677
6778* GraphQL
68- * Providers authentication helpers
6979* Attach/Detach entry relationship
7080
7181## Credits
0 commit comments