GithubHelp home page GithubHelp logo

account-service's Introduction

Account Service

  • Require:
    • MySQL

How to run

After cloned this repo into your machine, follow this step:

Configuration .yml file

Open application.yml file in src/main/resource/application.yml set url of your local MySQL database and username & password of your MySQL user.

Run Spring Boot

To run application in your local machine use this command, it will compile, test and start this application.

$ mvn spring-boot:run

Get Authorization Access Token

Use POSTMAN reqeust to http://localhost:8080/oauth/token with Authorization type Basic Auth username= app-client & password= noonewilleverguess and parameters scope = openid & grant_type = client_credentials

You will get response like this with access_token

{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJvcGVuaWQiXSwiZXhwIjoxNTcxNTI0MzUzLCJqdGkiOiI5MTNkOTNiYi05MzMxLTQwYzMtOGU4Ny1jZjdhZDM3ZDdkMjIiLCJjbGllbnRfaWQiOiJhcHAtY2xpZW50In0.nXVYQwKpW62s4Hn3q1eeg_Q9_XD56dSrcxMdBIujHtI",
    "token_type": "bearer",
    "expires_in": 43199,
    "scope": "openid",
    "jti": "913d93bb-9331-40c3-8e87-cf7ad37d7d22"
}

Register Account

POST Request to Account Service endpoint http://localhost:8080/api/accounts with request body as information of account and Authorization type Bearer Token with access token.

POST http://localhost:8080/api/accounts

Body:
{
	"username": "john.doe",
	"password": "P@ssw0rd",
	"first_name": "John",
	"last_name": "Done",
	"phone_number": "08123456789",
	"address": "123, Bangkok",
	"email": "[email protected]",
	"salary": 20000
}

Response:
{
    "status": "Created",
    "data": {
        "username": "john.doe",
        "firstName": "John",
        "lastName": "Done",
        "phoneNumber": "08123456789",
        "address": "123, Bangkok",
        "email": "[email protected]",
        "salary": 20000.0,
        "memberType": "SILVER",
        "referenceCode": "201910206789"
    }
}

Retrive Account

GET Requst to Account Service endpoint http://localhost:8080/api/accounts/{reference_code} with Authorization type Bearer Token with access token then will get response as account information.

{
    "status": "OK",
    "data": {
        "username": "john.doe",
        "firstName": "John",
        "lastName": "Done",
        "phoneNumber": "08123456789",
        "address": "123, Bangkok",
        "email": "[email protected]",
        "salary": 20000.0,
        "memberType": "SILVER",
        "referenceCode": "201910206789"
    }
}

account-service's People

Contributors

iphayao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.