Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Connect

Lucas Garcia edited this page Sep 5, 2018 · 4 revisions

Introduction

TO DO

Dependencies

import static br.com.moip.helpers.PayloadFactory.payloadFactory;
import static br.com.moip.helpers.PayloadFactory.value;

Features

Index

Ask for OAuth authorization

String[] scopes = {"TRANSFER_FUNDS", "RECEIVE_FUNDS"};

String url = Moip.API.connect().buildUrl("APP-DVLJHW59IKOS", "http://www.exemplo.com.br/retorno", scopes, setup);

System.out.println(url);

Generate Access Token

Map<String, Object> body = payloadFactory(
    value("client_id", "APP-DVLJHW59IKOS"),
    value("client_secret", "31afe1ce89fe45b7975ade3024007370"),
    value("redirect_uri", "http://www.exemplo.com.br/retorno"),
    value("grant_type", "authorization_code"),
    value("code", "b50f8d4c3932a38903d842bed70783db4183d04e")
);

Map<String, Object> accessToken = Moip.API.connect().generateAccessToken(body, setup);

System.out.println(accessToken);

Refresh Access Token

Map<String, Object> body = payloadFactory(
    value("grant_type", "refresh_token"),
    value("refresh_token", "599151f5954e401c8d169d5fa83c25ba_v2")
);

Map<String, Object> refreshToken = Moip.API.connect().refreshAccessToken(body, setup);

System.out.println(refreshToken);
Clone this wiki locally