Skip to content
Permalink
Browse files

Adds new basic auth helper, updates docs (#10)

  • Loading branch information...
jacobemerick committed Mar 27, 2019
1 parent 6dfc125 commit 564acdb4bd5a8f262beacb429040a65f40669adf
@@ -78,11 +78,8 @@ The following example uses the variables `applicationClientId` and `applicationC

```javascript
const sstk = require('shutterstock-api');
const apiClient = sstk.ApiClient.instance;

const basicAuth = apiClient.authentications['basic'];
basicAuth.username = applicationClientId;
basicAuth.password = applicationClientSecret;
sstk.setBasicAuth(applicationClientId, applicationClientSecret);

const api = new sstk.ImagesApi();
```
@@ -30,11 +30,8 @@ Method | HTTP request | Description
const sstk = require('shutterstock-api');
{{#hasAuthMethods}}
{{#authMethods}}{{#isBasic}}
const apiClient = sstk.ApiClient.instance;
// To use HTTP basic authorization:
const {{{name}}} = apiClient.authentications['{{{name}}}'];
{{{name}}}.username = client_id;
{{{name}}}.password = client_secret;{{/isBasic}}{{#isApiKey}}
sstk.setBasicAuth(client_id, client_secret);{{/isBasic}}{{#isApiKey}}
// To use OAuth access token authorization:
sstk.setAccessToken(process.env.SHUTTERSTOCK_API_TOKEN);
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
@@ -59,6 +59,11 @@
<importPath>: <importPath></apis></apiInfo>
};

exports.setBasicAuth = function(username, password) {
exports.ApiClient.instance.authentications['basic'].username = username;
exports.ApiClient.instance.authentications['basic'].password = password;
};

exports.setAccessToken = function(token) {
exports.ApiClient.instance.authentications['customer_accessCode'].accessToken = token;
};

0 comments on commit 564acdb

Please sign in to comment.
You can’t perform that action at this time.