인증 토큰 발급 개요 API 호출을 위한 Acccess Token 발급합니다. Access Token은 다른 API를 호출하기 위해 필요합니다. signOK에서 발급한 API ID, API Secret Key를 HTTP Header의 Authorization항목에 Basic 인증 방식으로 설정합니다.
URL POST oauth/token
요청 데이터 항목 타입 위치 설명 Authorization String Header API ID, Secret Key Basic 인증값 ( API ID:Secret Key 를 BASE64 Encoding한 값 ) grant_type String body password 고정 username String body api 고정 password String body nopassword 고정
요청 데이터 예시 HTTP POST / oauth / token HTTP / 1.1
Host : doc . signok . com
Content - Type : application / x - www - form - urlencoded
Authorization : Basic c2FtcGxlOnNhbXBsZQ ==
Content - Length : 52
grant_type = password & username = api & password = nopassword
응답 데이터 항목 타입 위치 설명 access_token String body access token refresh_token String body access token 만료 시 token 갱신을 위한 refresh token expires_in String body access token 만료 시간
응답 데이터 예시 JSON Web Token {
" access_token " : " ACCESS_TOKEN " ,
" token_type " : " bearer " ,
" refresh_token " : " REFRESH_TOKEN " ,
" expires_in " : 43199 ,
" scope " : " read write " ,
" jti " : " 12345678-1234-1234-1234-123456789012 "
}
예제 코드 Java C# JavaScript Node.js Python OkHttpClient client = new OkHttpClient (). newBuilder ()
. build ();
MediaType mediaType = MediaType . parse ( " application/x-www-form-urlencoded " );
RequestBody body = RequestBody . create ( mediaType , " grant_type=password&username=api&password=nopassword " );
Request request = new Request . Builder ()
. url ( " https://doc.signok.com/oauth/token " )
. method ( " POST " , body )
. addHeader ( " Content-Type " , " application/x-www-form-urlencoded " )
. addHeader ( " Authorization " , " Basic c2FtcGxlOnNhbXBsZQ== " )
. build ();
Response response = client . newCall ( request ). execute ();
var client = new RestClient ( " https://doc.signok.com/oauth/token " );
client . Timeout = - 1 ;
var request = new RestRequest ( Method . POST );
request . AddHeader ( " Content-Type " , " application/x-www-form-urlencoded " );
request . AddHeader ( " Authorization " , " Basic c2FtcGxlOnNhbXBsZQ== " );
request . AddParameter ( " grant_type " , " password " );
request . AddParameter ( " username " , " api " );
request . AddParameter ( " password " , " nopassword " );
IRestResponse response = client . Execute ( request );
Console . WriteLine ( response . Content );
var myHeaders = new Headers ();
myHeaders . append ( " Content-Type " , " application/x-www-form-urlencoded " );
myHeaders . append ( " Authorization " , " Basic c2FtcGxlOnNhbXBsZQ== " );
var urlencoded = new URLSearchParams ();
urlencoded . append ( " grant_type " , " password " );
urlencoded . append ( " username " , " api " );
urlencoded . append ( " password " , " nopassword " );
var requestOptions = {
method : ' POST ' ,
headers : myHeaders ,
body : urlencoded ,
redirect : ' follow '
};
fetch ( " https://doc.signok.com/oauth/token " , requestOptions )
. then ( response => response . text ())
. then ( result => console . log ( result ))
. catch ( error => console . log ( ' error ' , error ));
var axios = require ( " axios " );
var qs = require ( " qs " );
var data = qs . stringify ({
" grant_type " : " password " ,
" username " : " api " ,
" password " : " nopassword "
});
var config = {
method : " post " ,
url : " https://doc.signok.com/oauth/tokenn " ,
headers : {
" Content-Type " : " application/x-www-form-urlencoded " ,
" Authorization " : " Basic c2FtcGxlOnNhbXBsZQ== "
},
data : data
};
axios ( config )
. then ( function ( response ) {
console . log ( JSON . stringify ( response . data ));
import http . client
conn = http . client . HTTPSConnection ( " doc.signok.com " )
headers = {
" Content-Type " : " application/x-www-form-urlencoded " ,
" Authorization " : " Basic c2FtcGxlOnNhbXBsZQ== "
}
payload = " grant_type=password&username=api&password=nopassword "
conn . request ( " POST " , " /oauth/token " , payload , headers )
res = conn . getresponse ()
data = res . read ()
print ( data . decode ( " utf-8 " ))