sala 2 03 o auth e cadastro de produtos - danilo santos

Post on 06-Jul-2015

235 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

3º Developers Conference MercadoLibre Brasil

TRANSCRIPT

Danilo Santos

OAUTH E CADASTRO DE ANÚNCIOS

Engenheiro de Software do MercadoLivre

Developer Conference

- OAuth 2.0

- Recursos

- Autenticação e Access Token

- Cadastrando um anúncio

Agenda

Developer Conference

OAuth 2.0 - Conceitos

Developer Conference

OAuth 2.0 - Conceitos

Developer Conference

OAuth 2.0 - Conceitos

Developer Conference

Recursos - Públicos

Método: GET

https://api.mercadolibre.com/users/4432317

Developer Conference

Recursos - Públicos

GET /users/4432317{ "id": 4432317, "nickname": "DANILO", "registration_date": "2007-02-07T17:52:38.000-04:00", "country_id": "BR", "user_type": "normal", "points": 98, "site_id": "MLB", "permalink": "http://perfil.mercadolivre.com.br/DANILO", "seller_reputation": {...}, "status": - { "site_status": "active", },}

Developer Conference

Recursos - Privados

Método: GET

https://api.mercadolibre.com/users/4432317?access_token=XXX

Developer Conference

Recursos - Privados

GET /users/4432317?access_token=XXX{ "id": 4432317, "nickname": "DANILO", "registration_date": "2007-02-07T17:52:38.000-04:00", "first_name": "Danilo", "last_name": "YXXXXXXX XXXXXX Santos", "country_id": "BR", "email": "xxxxxxxxxx@xxxxxxx.com.br", "identification": - { "type": "CPF", "number": "XXXXXXXXXX", }, "address": {...}, "phone": {...}, "user_type": "normal", "tags": - [...],

Developer Conference

Autenticação

Client Side Server Side

Developer Conference

Autenticação - Client Side

Client Side

Developer Conference

Autenticação - Client Side

Usuario acessa APP

Developer Conference

Autenticação - Client Side

Redireciona Usuario

Usuario acessa APP

Developer Conference

Autenticação - Client Side

ACCESS_TOKEN

Redireciona Usuario

Usuario acessa APP

Developer Conference

Autenticação - Server Side

Server Side

Developer Conference

Autenticação - Server Side

Redireciona Usuario

Usuario acessa APP

Developer Conference

Autenticação - Server Side

Redireciona Usuario

GET

Usuario acessa APP

Developer Conference

Autenticação - Server Side

Redireciona Usuario

GET

POST

Usuario acessa APP

Developer Conference

Autenticação - Server Side

Redireciona Usuario

GET

POST

ACCESS_TOKEN

Usuario acessa APP

Developer Conference

Autenticação - Server Side

Redireciona Usuario

GET

POST

ACCESS_TOKEN

REFRESH_TOKEN

Usuario acessa APP

Developer Conference

Autenticação - Server Side

{ "access_token":"APP_USR-334068594158e62fe6652f__I_M__-163745308", "token_type":"bearer", "expires_in":21600, "scope":"offline_access read write", "refresh_token":"TG-53e107eee4b0c9feba738cff"}

JSON de Retorno:

Developer Conference

- OAuth 2.0

- Recursos

- Autenticação e Access Token

- Cadastrando um anúncio

Agenda

Developer Conference

Cadastro de Anúncios

https://api.mercadolibre.com/items

Developer Conference

- Título- Categoria- Preço- Quantidade- Nível de exposição- Imagens- Descrição

POST /items - Cadastrar um anúncio

Developer Conference

POST /items - Cadastrar um anúncio

JSON enviado:

{ "title": "Apple Iphone 5s 16gb 4g Original Promoção", "category_id": "MLB123612", "price": 2000, "currency_id": "BRL", "initial_quantity": 50, "listing_type_id": "silver", "condition": "new", "pictures": { "source": "http://static.hsw.com.br/gif/how-to-draw-buildings-58.jpg"}, "video_id": null, "descriptions": "item: <strong> Iphone 5s Imperdível!!! </strong>",

Developer Conference

POST /items - Cadastrar um anúncio

APPPOST

Developer Conference

POST /items - Cadastrar um anúncio

APPPOST

APP201 Created

Developer Conference

Na prática

Autenticando

Cadastrando um Anúncio

Developer Conference

Perguntas?

Developer Conference

OBRIGADO!

top related