1.2.0 • Published 6 years ago

dribbble-oauth2 v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Dribble-OAUTH2

Library to easy access and use dribbble OAuth2 api.

Getting Started

const settings = {
  'client_id': YOUR_CLIENT_ID,
  'client_secret': YOUR_CLIENT_SECRET
};
const dribble = require('./dribbble-oauth2/index')(settings); // return instance of dribble (singleton)
Dribbble instance can init later. Just call setSettings mehtod/
const dribble = require('dribbble-oauth2')();
// ... another code 
    const settings = {
        'client_id': YOUR_CLIENT_ID,
        'client_secret': YOUR_CLIENT_SECRET
  };
  dribble.setSettings(settings);

  const url = dribble.authorize(REDIRECT_URL, 'public+upload');
Init dribble and set local url when you will get code (note, redirect url should be save in a dribble account)

Scope can be 'public', 'upload' or 'public+upload';

const url = dribble.authorize(redirectUrl, scope); // return link (type = string);

Go to link returned from the authorize method and login into Dribbble using your credentials. After this you will be redirected to the setted url. Use code in params and get the access_token.

app.get('/redirect', (req, res) => {     // Example route
  const code = req.query.code;           // Get the code from url params

  dribble.getToken(code)                    
    .then(response => {
      if (response.status) {                
        res.json(response.statusText)
      } else {
        res.json(response)               // Contains an access_token which you can use in future requests
      }                                     
    });
});
Use predefined access_token
const dribble = DribbleOauth()();
dribble.setAccessToken(ACCESS_TOKEN);

API

Shots

Get all shots

dribble.api.shot.getAll();

Get shot by id

NameTypeDescription
idnumberShot id
dribble.api.shot.get(id);   

Create a shot

NameTypeDescription
imagefileRequired. The image file must be exactly 400x300 or 800x600 resolution, no larger than 8 megabytes, and be a GIF, JPG or PNG.
titlestringRequired. The title of the shot.
descriptionstringThe shot description.
low_profilebooleanSpecify true if the shot is Low Profile.
rebound_source_idintegerAn ID of a shot that the new shot is a rebound of.

The authenticated user must either be a member of the team or be authenticated as the same team.

dribble.api.shot.create(settings);

Update a shot

NameTypeDescription
idnumberShot Id.
descriptionstringShot description.
low_profilebooleanSpecify true if the shot is Low Profile.
scheduled_fortimestampIf the shot is not already published, will reschedule the shot to publish at the timestamp provided. Timestamp must be in ISO 8601 format. The authenticated user must be a pro, a team, or a member of a team.
tagsarrayTags for the shot. Limited to a maximum of 12 tags. If any existing tags are not provided they will be removed.
team_idintegerAn ID of a team to associate the shot with. The authenticated user must be on the team. If any empty value is provided the team association will be removed.
titlestringThe title of the shot.
dribble.api.shot.update(id, settings);

Delete shot by id

NameTypeDescription
idnumberShot id.
dribble.api.shot.delete(id);   

User

Get the authenticated user

dribble.api.user.get();   

Projects

List projects

dribble.api.project.getAll();   

Create a project

NameTypeDescription
namestringRequired. The name of the project.
descriptionstringThe project description.
dribble.api.project.create(settings);   

Update a project

NameTypeDescription
idnumberProject id.
namestringThe name of the project.
descriptionstringThe project description.
dribble.api.project.update(id, settings);   

Delete a project

NameTypeDescription
idnumberProject id.
dribble.api.user.delete(id);   

Attachments

Create an attachment

NameTypeDescription
filefileRequired. The attachment file must be no larger than 10 megabytes.
dribble.api.attachment.create(shotId, settings);   

Delete an attachment

dribble.api.attachment.delete(shotId, attachmentId);