SePay OAuth2 Overview

Learn about the OAuth2 authentication mechanism for integrating with SePay API.


Introduction

  • SePay has implemented the OAuth2 authentication mechanism, making integration with our system easier and more secure for partners.
    This document provides detailed guidance on how to use OAuth2 to connect to SePay’s API endpoints.

What is OAuth2?

  • OAuth2 is a standard authorization protocol that allows third-party applications to access user resources without requiring login credentials.

    OAuth2 SePay
    OAuth2 SePay
  • OAuth2 provides the following benefits:

    • Security: No need to share login credentials with third-party apps
    • Control: Users can limit the access scope for each application
    • Flexibility: Easy to revoke access without changing passwords
    • Standardized: Widely supported and adopted by many online services

Benefits of Using OAuth2 with SePay

  • Implementing OAuth2 brings several key advantages when integrating with SePay:
High Security

Secure authentication without sharing login credentials, minimizing security risks.

Detailed Access Control

Granular access control to each endpoint, helping you manage which data and features can be accessed.

Limited Access Scope

Restrict the access scope for third-party apps, ensuring only necessary permissions are granted.

Refresh Token

Token refresh mechanism to maintain secure connection without re-authentication.

Scopes

  • SePay defines scopes to control access to specific APIs:
ScopeDescription
bank-account:readPermission to read bank account information
transaction:readPermission to read transaction information
webhook:readPermission to read webhook information
webhook:writePermission to write webhook information
webhook:deletePermission to delete webhook information
profilePermission to read user profile information
companyPermission to read company information
  • When registering an application, you can request one or multiple scopes.
    Users will be prompted to grant access during the authentication process.

OAuth2 Flow Overview

  • The OAuth2 flow in SePay follows the standard authentication process with the following steps:
1
Register Application

Obtain `client_id` and `client_secret` from SePay via the Developer Portal.

2
Request Authorization

Redirect users to SePay’s authorization screen to grant access.

3
Receive Authorization Code

SePay redirects the user back to your application with an authorization code.

4
Exchange Code for Token

Send an API request to SePay to exchange the authorization code for an access token.

5
Use the Token

Attach the access token to the header of API requests for authentication.

6
Refresh the Token

Use the refresh token to obtain a new access token when it expires.

Detailed instructions for each step in the OAuth2 flow can be found in
Authentication Flow

API Base URL

  • All SePay OAuth2 APIs share the same base URL:
    https://my.sepay.vn/api/v1

  • When making API requests, append the specific endpoint path after the base URL. Example:

EndpointFull URLDescription
/bank-accountshttps://my.sepay.vn/api/v1/bank-accountsAPI to retrieve bank account list
/transactionshttps://my.sepay.vn/api/v1/transactionsAPI to retrieve transaction list
/webhookshttps://my.sepay.vn/api/v1/webhooksAPI to manage webhooks
/mehttps://my.sepay.vn/api/v1/meAPI to retrieve current user information
/companieshttps://my.sepay.vn/api/v1/companiesAPI to retrieve company information

API Versioning

  • The "v1" part of the base URL represents the API version.
    SePay uses versioning to ensure backward compatibility when updates are made.
  • Current version: v1 (https://my.sepay.vn/api/v1)
  • When a new API version is released, SePay will announce and update the documentation.
    We always maintain older versions for a reasonable period to allow applications to upgrade smoothly.
Note

All API requests must include an Access Token in the Authorization header
as described in Access Token