0
Google Api 서비스에서 무기명 토큰에 대한 인증 코드를 교환해야합니다. Oauth2 흐름을 설명하는 OauthPlayground이라는 멋진 응용 프로그램이 있습니다. 토큰은이 같은 요청을 사용하여 교환 :각도 교환이 무기 토큰에 대한 토큰에 액세스 Oauth2
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-length: 233
content-type: application/x-www-form-urlencoded
user-agent: google-oauth-playground
code=4%2F6RMgcR3WKuY8_bIaZa0o8P6xfxMKZh1f6AZmh9Q-h6Y&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&client_id=407408718192.apps.googleusercontent.com&client_secret=************&scope=&grant_type=authorization_code
내가 Google developer console에서 내 응용 프로그램을 등록하고 내 자신의 CLIENT_ID 및 client_secret을 가지고있다. 하지 작업을 수행 내 코드는 다음과 같습니다 : 요청과 함께 전송
tryGetBearers(){
let connString='www.googleapis.com/oauth2/v4/token';
let connBody='code='+this.accessToken;
connBody+='&redirect_uri='+this.redirect_uri
connBody+='&client_id='+this.client_id
connBody+='&client_secret='+this.client_secret
connBody+='&scope=&grant_type=authorization_code'
let headers = new Headers();
headers.append('content-type', 'application/x-www-form-urlencoded');
this.http.post(connString,connBody,{headers:headers}).subscribe(
res=>{console.log(res);},
(error)=>{console.log(error);
}
);
}
예 본문은 다음과 같습니다
이code=4/Q5p52c8zMfwzAKErog-7QUJzv7aYGyAlCDz_5KE0Mgw&redirect_uri=http://localhost:4200&client_id=665991054229-jmd9i1ovcohglkrlbu1ff1nih9j1cqia.apps.googleusercontent.com&client_secret=hnrh1eGPKFmdEWkdWna7zs6K&scope=&grant_type=authorization_code
함수의 응답은 단지 404 찾을 수 없습니다. 나는 무엇이 잘못되었는지 전혀 모른다.