Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

액세스 토큰으로 사용자 정보 가져오기 - 카카오 #71

Open
bluesun147 opened this issue Aug 11, 2022 · 0 comments
Open
Assignees

Comments

@bluesun147
Copy link
Member

axios https://kapi.kakao.com/v2/user/me 사용.

액세스 토큰 넣었을 때 나오는 값.
ㄴ 액세스 토큰으로 사용자 정보 구할 수 있다.


잘못된토큰값넣었을때
[Nest] 16560 - 2022. 08. 12. 오전 1:50:45 ERROR [ExceptionsHandler] Request failed with status code 401
[Nest] 16560 - 2022. 08. 12. 오전 1:50:45 ERROR [ExceptionsHandler] undefined
Eb8Ss1l-33vH3Em9mZek3UtUmSEQCx2adgucpAv5CisMqAAAAYKNz6eO
user_ifo is {
status: 200,
statusText: 'OK',
headers: {
date: 'Thu, 11 Aug 2022 16:50:49 GMT',
server: 'Apache',
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
'access-control-allow-headers': 'Content-Type,X-Requested-With,Accept,Authorization,Origin,KA,Cache-Control,Pragma',
'quota-type': 'INC_AND_CHECK',
'content-type': 'application/json;charset=UTF-8',
'content-length': '966',
connection: 'close'
},
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function] },
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, /',
Authorization: 'Bearer Eb8Ss1l-33vH3Em9mZek3UtUmSEQCx2adgucpAv5CisMqAAAAYKNz6eO',
'User-Agent': 'axios/0.27.2'
},
method: 'get',
url: 'https://kapi.kakao.com/v2/user/me',
data: undefined
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
prefinish: [Function: requestOnPrefinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'kapi.kakao.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 10,
connecting: false,
_hadError: false,
_parent: null,
_host: 'kapi.kakao.com',
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular *1],
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 443,
[Symbol(kHandle)]: [TLSWrap],
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(RequestTimeout)]: undefined
},
_header: 'GET /v2/user/me HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Authorization: Bearer Eb8Ss1l-33vH3Em9mZek3UtUmSEQCx2adgucpAv5CisMqAAAAYKNz6eO\r\n' +
'User-Agent: axios/0.27.2\r\n' +
'Host: kapi.kakao.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/v2/user/me',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [Circular *1],
responseUrl: 'https://kapi.kakao.com/v2/user/me',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 18,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0,
[Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'kapi.kakao.com',
protocol: 'https:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'https://kapi.kakao.com/v2/user/me',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
authorization: [Array],
'user-agent': [Array],
host: [Array]
}
},
data: {
id: 2128182556,
connected_at: '2022-07-13T04:35:16Z',
properties: {
nickname: '김해찬',
profile_image: 'http://k.kakaocdn.net/dn/chyHjR/btqOnZZP96k/0peqSdACIgUaPadgSPM4GK/img_640x640.jpg',
thumbnail_image: 'http://k.kakaocdn.net/dn/chyHjR/btqOnZZP96k/0peqSdACIgUaPadgSPM4GK/img_110x110.jpg'
},
kakao_account: {
profile_nickname_needs_agreement: false,
profile_image_needs_agreement: false,
profile: [Object],
has_email: true,
email_needs_agreement: false,
is_email_valid: true,
is_email_verified: true,
email: '[email protected]',
has_age_range: true,
age_range_needs_agreement: false,
age_range: '20~29',
has_birthday: true,
birthday_needs_agreement: true,
has_gender: true,
gender_needs_agreement: true
}
}
}
user_id is 2128182556

@bluesun147 bluesun147 self-assigned this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant