This is an auto-generated translation

서명 인증

모든 API 요청에 필요한 Rapid 서명 인증 방법입니다.

API 키 인증 및 액세스

HTTP 인증 헤더를 사용하여 각 요청과 함께 API 키 및 SHA-512 서명 해시를 전송합니다. 서명 해시는 API 키와 공유 암호, UNIX 타임스탬프로 구성됩니다.

API 키가 없는 경우 시작하기 페이지에서 계정 설정과 관련한 정보와 지침을 확인하실 수 있습니다.

몇몇 Rapid API는 서명 인증이 아닌 OAuth 2.0 인증 프로세스를 사용합니다.

OAuth 2.0 인증에 대해 자세히 알아보기

인증 헤더 생성

Rapid에서 아래 형식을 사용하려면 인증 헤더가 필요합니다. 필요한 EAN 접두사에 유의해 주세요. 이 접두사는 올바른 인증 규칙이 요청에 적용되도록 합니다.

Authorization: EAN APIKey=yourAPIKey,Signature=sha512Hash,timestamp=yourUNIXTimestamp

``signature 값은 API 키 + 공유 암호 + UNIX 타임스탬프(초) 연결의 언솔티드 SHA-512 해시입니다.

timestamp 값은 signature를 생성하는 데 사용한 동일해야 합니다. 다른 타임스탬프 값을 제공하면 Rapid에서 서명 해시 값을 확인하지 못해 요청이 거부됩니다.

아래 전체 인증 헤더의 예가 나와 있습니다.

Authorization: EAN APIKey=yourAPIKey,Signature=Mgup2Azf,timestamp=1476739212

인증 헤더 확인

테스트 요청을 시도하기 전에 Rapid 서명 생성기에서 자체 코드를 테스트해 주세요.

참고: NTP 시계 동기화

Rapid는 NTP(Network Time Protocol)를 사용하여 내부 서버 시간을 동기화합니다. NTP를 사용하는 경우에도 시계 동기화 문제가 발생해서는 안 됩니다. 대부분의 최신 운영체제는 이 서비스 또는 이와 유사한 시간 동기화 서비스를 지원합니다. OS 설명서를 참조해 주세요. 시스템은 적절한 클럭 드리프트를 수용할 수 있도록 서버 타임스탬프 앞뒤로 최대 5분의 타임스탬프를 허용합니다.

서명 생성 코드 샘플

PHP

$apiKey = "abcdefg";
$secret = "1a2bc3";
$timestamp = time();
$authHeader = 'Authorization: EAN APIKey=' . $apiKey . ',Signature=' . hash("sha512", $apiKey.$secret.$timestamp) . ',timestamp=' . time();

JavaScript

var crypto = require('crypto');
var request = require('request');
var apiKey = '123';
var secret = '123';
var timestamp = Math.round(new Date().getTime() / 1000);
var hash = crypto.createHash('sha512').update(apiKey + secret + timestamp).digest('hex');
var authHeaderValue = 'EAN APIKey=' + apiKey + ',Signature=' + hash + ',timestamp=' + timestamp;

Java

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Timestamp;
import java.util.Date;
String apiKey = "123";
String secret = "123";
Date date= new java.util.Date();
Long timestamp = (date.getTime() / 1000);
String signature = null;
try {
   String toBeHashed = apiKey + secret + timestamp;
   MessageDigest md = MessageDigest.getInstance("SHA-512");
   byte[] bytes = md.digest(toBeHashed.getBytes("UTF-8"));
   StringBuilder sb = new StringBuilder();
   for(int i=0; i< bytes.length ;i++){
       sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
   }
   signature = sb.toString();
} catch (NoSuchAlgorithmException e) {
   e.printStackTrace();
} catch (UnsupportedEncodingException e) {
   e.printStackTrace();
}
String authHeaderValue = "EAN APIKey=" + apiKey +  ",Signature=" + signature + ",timestamp=" + timestamp;

Python

#!/usr/bin/env python
import hashlib
import time
apiKey = "123"
secret = "123"
timestamp = str(int(time.time()));
authHeaderValue = "EAN APIKey=" + apiKey + ",Signature=" + hashlib.sha512(apiKey+secret+timestamp).hexdigest() + ",timestamp=" + timestamp

Ruby

require 'digest'
apiKey="123"
secret="123"
timestamp = Time.now.to_i
toBeHashed = "#{apiKey}#{secret}#{timestamp}"
signature = Digest::SHA2.new(512).hexdigest(toBeHashed)
authHeaderValue = "EAN APIKey=#{apiKey},Signature=#{signature},timestamp=#{timestamp}"

C#

String apiKey = "123";
String secret = "123";
TimeSpan epochTicks = new TimeSpan(new DateTime(1970, 1, 1).Ticks);
TimeSpan unixTicks = new TimeSpan(DateTime.UtcNow.Ticks) - epochTicks;
double unixTime = (int)unixTicks.TotalSeconds;
var toBeHashed = apiKey + secret + unixTime;
var bytes = System.Text.Encoding.UTF8.GetBytes(toBeHashed);
using (var hash = System.Security.Cryptography.SHA512.Create())
{
   var hashedInputBytes = hash.ComputeHash(bytes);
   var hashedInputStringBuilder = new System.Text.StringBuilder(128);
   foreach (var b in hashedInputBytes)
       hashedInputStringBuilder.Append(b.ToString("X2"));
   var signature = hashedInputStringBuilder.ToString();
   var authHeaderValue = "EAN APIKey=" + apiKey + ",Signature=" + signature +",timestamp=" + unixTime;
}

Perl

use strict;
use Crypt::Digest::SHA512 qw(sha512_hex);
my $apiKey = '123';
my $secret = '123';
my $timestamp = time;
my $sig = sha512_hex($apiKey . $secret . $timestamp);
my $authHeaderValue = "EAN APIKey=".$apiKey.",Signature=".$sig.",timestamp=".$timestamp;
print $authHeaderValue;

GoLang

apiKey := "123"
secret := "123"
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
c := sha512.New()
c.Write([]byte(apiKey + secret + timestamp))
signature := hex.EncodeToString(c.Sum(nil))
authHeaderValue := "EAN APIKey=" + apiKey + ",Signature=" + signature + ",timestamp=" + timestamp

공유 암호 보호

제공받은 공유 암호는 요청 데이터의 보안에 매우 중요합니다. 공유 암호를 비밀번호와 같이 취급해 주세요. 공개적으로 액세스 가능한 사이트 또는 앱 코드에 원시 값을 포함해서는 안 됩니다. Rapid를 통합하도록 승인되면 공유 암호와 API 키가 제공됩니다.

이 페이지가 도움이 되었나요?
이 콘텐츠를 어떻게 개선하면 좋을까요?
더 나은 Developer Hub를 만드는 데 도움을 주셔서 감사합니다!