์๋น์ค ๊ณ์ ํ ํฐ ์์ฑ
์ด ํ์ด์ง์ ๋ด์ฉ
์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ Atlas ๊ด๋ฆฌ API ์ ์์ฒญํ๋ ค๋ฉด ํ ํฐ์ด ํ์ํฉ๋๋ค. ํ์ต ๋ณด๋ ค๋ฉด ์๋น์ค ๊ณ์ ๊ฐ์๋ฅผ ์ฐธ์กฐํ์ธ์.
Resource
POST https://cloud.mongodb.com/api/oauth/token
์์ฒญ ๊ฒฝ๋ก ๋งค๊ฐ๋ณ์
์ด ์๋ํฌ์ธํธ๋ HTTP ์์ฒญ ๊ฒฝ๋ก ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ฉํ์ง ์์ต๋๋ค.
์์ฒญ ์ฟผ๋ฆฌ ๋งค๊ฐ๋ณ์
๋ค์ ์ฟผ๋ฆฌ ๋งค๊ฐ๋ณ์๋ ์ ํ ์ฌํญ์ ๋๋ค.
์ด๋ฆ | ์ ํ | ํ์์ฑ | ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
---|---|---|---|---|
pretty | ๋ถ์ธ | ์ต์
| false | |
envelope | ๋ถ์ธ | ์ต์
| ์๋ต์ ์๋ฒจ๋กํ์ ๋ํํ ์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ด๋ ํ๋๊ทธ์ ๋๋ค. ์ผ๋ถ API ํด๋ผ์ด์ธํธ๋ HTTP ์๋ต ํค๋ ๋๋ ์ํ ์ฝ๋์ ์ก์ธ์คํ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ์ฟผ๋ฆฌ์์ ๊ฒฐ๊ณผ ๋ชฉ๋ก์ ๋ฐํํ๋ ์๋ํฌ์ธํธ์ ๊ฒฝ์ฐ | false |
์์ฒญ ๋ณธ๋ฌธ ๋งค๊ฐ๋ณ์
์ด ์๋ํฌ์ธํธ๋ HTTP ์์ฒญ ๋ณธ๋ฌธ ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ฉํ์ง ์์ต๋๋ค.
์๋ต
์๋ต์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค.
์ด๋ฆ | ์ ํ | ์ค๋ช
|
---|---|---|
access_token | ๋ฌธ์์ด | API ์์ฒญ ์ธ์ฆ์ ์ํ ์๋น์ค ๊ณ์ ์ก์ธ์ค ํ ํฐ์
๋๋ค. |
token_type | ๋ฌธ์์ด | ํ ํฐ ๊ถํ ๋ถ์ฌ ๋ฉ์ปค๋์ฆ์ผ๋ก, ์ฌ๊ธฐ์๋ Bearer ๋ก ํ์๋ฉ๋๋ค. |
expires_in | integer | ์ก์ธ์ค ํ ํฐ์ด ์ ํจํ ๊ธฐ๊ฐ(์ด)์
๋๋ค. |
์์ฒญ ์์
๋ค์ ์์ ์์ {BASE64-AUTH}
์ ๊ธฐ๋ณธ64์ธ์ฝ๋ฉ๋ ์๋น์ค ๊ณ์ ํด๋ผ์ด์ธํธ ID ๋ฐ ์ํฌ๋ฆฟ์ผ๋ก ๋ฐ๊ฟ๋๋ค. ํ์ต ๋ด์ฉ ์ API ์์ฒญํ๊ธฐ๋ฅผ ์ฐธ์กฐํ์ธ์.
curl --request POST \ --url https://cloud.mongodb.com/api/oauth/token \ --header 'accept: application/json' \ --header 'cache-control: no-cache' \ --header 'authorization: Basic {BASE64-AUTH}' \ --header 'content-type: application/x-www-form-urlencoded' \ --data 'grant_type=client_credentials'
์๋ต ์์
์๋ต ํค๋
200 OK Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Connection: keep-alive Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion}
400 Bad Request Date: {dateInUnixFormat} Content-Type: application/json Content-Length: {requestLengthInBytes} Server: mdbws Strict-Transport-Security: max-age=31536000; includeSubdomains; X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion} ...
401 Unauthorized Content-Type: application/json;charset=ISO-8859-1 Date: {dateInUnixFormat} WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false Content-Length: {requestLengthInBytes} Connection: keep-alive
403 Forbidden Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Connection: keep-alive Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion} ...
429 Too Many Requests Retry-After: {retryAfterValue} Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Connection: keep-alive Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion} ...
500 Internal Server Error Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion} ...
503 Service Unavailable Retry-After: {retryAfterValue} Vary: Accept-Encoding Content-Type: application/json Strict-Transport-Security: max-age=300 Date: {dateInUnixFormat} Content-Length: {requestLengthInBytes} X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion} ...
์๋ต ๋ณธ๋ฌธ
{ "access_token":"eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IjAwMDAwMDAwLTQwMDBtLTQ0MGEIXkY0IH4IMF84MGYMX2FtperB2miniFzHCJ9.eyJpc3MiOiJodHRwczUvYWxkZXYubW9uZ29kYi5jb20iLCJhdWQiOiJhcGk6Ly9hZG1pbiIsInN1YiI6ImZha2Vfc3ViX2lkXzAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwIiwic2lkIjoiZmFrZTNfaWRfMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwIiwic2Vzc2lvblN1YiI6ImZha2Vfc2lkXzAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwIIDmVlc1NX4adGVyaCBJRCJvbmcxISS8zdeD0pyQwMjNlIiwiYWN0b3JJZCI6ImZha2Vfc2lkXzAwMDAwMDAwMDAwMDOIi8wMDAwMDAwMCIsImlhdCI6MTIzNDU2Nzg5MCwiZXhwIjoxMjM0NTc0OTgwLCJqdGkiOiJmYWtlLWp0aS02MOwNDBQNDBdDOGhyES8xOTY1OGEtMDAwMDAwMDAwMDAwMDAwMDAwMGIwNjRGM3NifQ==.jmbo9d_fgfk32FGB423f09SF0kFSDFoQxh3j9FZ2", "expires_in":3600, "token_type":"Bearer" }
{ "error_description": "The provided credentials are not valid.", "error": "invalid_request" }
{ "error_description": "Invalid grant type.", "error": "unsupported_grant_type" }
{ "error_description": "Invalid grant.", "error": "invalid_grant" }
{ "error_description": "Invalid credentials provided.", "error": "invalid_client" }
{ "error_description": "IP access list validation failed for the service account.", "error": "access_denied" }
{ "error_description": "Resource {URL} is limited to 10 requests every 1 minutes.", "error": "rate_limited" }
{ "error_description": "Unexpected error.", "error": "server_error" }