module MercadoPago::Authentication

Constants

CONTENT_HEADERS

Public Class Methods

access_token(client_id, client_secret) click to toggle source

Receives the client credentials and makes a request to oAuth API. On success, returns a hash with the access data; on failure, returns nil.

To get your client credentials, access: www.mercadopago.com/mlb/ferramentas/aplicacoes

  • client_id

  • client_secret

# File lib/mercadopago/authentication.rb, line 19
def self.access_token(client_id, client_secret)
  payload = {
    grant_type: 'client_credentials',
    client_id: client_id,
    client_secret: client_secret }

  MercadoPago::Request.wrap_post('/oauth/token', payload, CONTENT_HEADERS)
end
refresh_access_token(client_id, client_secret, refresh_token) click to toggle source

Receives the client credentials and a valid refresh token and requests a new access token.

  • client_id

  • client_secret

  • refresh_token

# File lib/mercadopago/authentication.rb, line 35
def self.refresh_access_token(client_id, client_secret, refresh_token)
  payload = {
    grant_type: 'refresh_token',
    client_id: client_id,
    client_secret: client_secret,
    refresh_token: refresh_token }

  MercadoPago::Request.wrap_post('/oauth/token', payload, CONTENT_HEADERS)
end