2013-01-05 2 views
0

나는 다음과 같은 경우 2.0 이메일 주소 : OAuth를

<cflocation url="https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&client_id=#Application.Google.client_id#&redirect_uri=http%3A%2F%2Fwww.PhillipSenn.com%2FLR%2FGoogle%2FCallback&response_type=code" addtoken="no"> 

는 다음 나는 "액세스 허용"제대로 "아니오 감사합니다"화면 얻을. 그런 다음 액세스 허용 및 콜백 화면이 올바르게 호출됩니다.

Q : 지금 어떻게해야합니까? 사용자의 전자 메일 주소를 확인해야합니다.

내가 보는 유일한 것 : url.code, 쓸모 없어 보입니다. 내가 다음 access_token이라는 것을 사용

https://www.googleapis.com/oauth2/v1/userinfo 

전화를해야합니까? 나는 JavaScript에 대해 이야기하고 있기 때문에 그렇게 생각하지 않는다. 나는이 모든 서버 측을하고있다. 게다가 사용자 프로필 정보가 필요하지 않습니다. 이메일 주소가 필요합니다.

편집 :

This link 유망 보인다.

답변

1

전화를 걸면 access_token이 표시되어 제한된 시간 동안 사용자 정보에 액세스 할 수 있습니다. 그것은 당신이 그것을 사용하는 문제가되지 않습니다, 서버 쪽 괜찮습니다.

<form method="post" action="https://accounts.google.com/o/oauth2/token"> 
    <input name="code" value="#url.code#"> 
    <input name="client_id" value="#Google.client_id#"> 
    <input name="client_secret" value="#Google.client_secret#"> 
    <input name="redirect_uri" value="#Google.redirect_uri#"> 
    <input name="grant_type" value="authorization_code"> 
    <input type="submit" name="getAccessToken" value="Get Access Token"> 
</form> 
+0

경우에 따라'''access_token'''이 만료 될 수 있으며 사용자 또는 사용자로부터 다시 가져 와서 새 것을 가져와야합니다. ''refresh_token''' (OAuth 제공 업체가 제공 한 경우)를 사용하여 – Zepplock

+0

어디서나 access_token을 볼 수 없습니다. 나는 url.code를 본다. 그게 다야? –

+0

전체 응답을 게시 할 수 있습니까? 여기에 따라야 할 Google 문서가 있습니다 : https://developers.google.com/accounts/docs/OAuth2UserAgent – Zepplock

0

구글 리디렉션 처음 access_token=youraccess_token이 있는지 확인, 다음을 수행해야

<cfhttp method="post" name="qry" url="https://accounts.google.com/o/oauth2/token"> 
    <cfhttpparam type="formfield" name="code" value="#url.code#"> 
    <cfhttpparam type="formfield" name="client_id" value="#Google.client_id#"> 
    <cfhttpparam type="formfield" name="client_secret" value="#Google.client_secret#"> 
    <cfhttpparam type="formfield" name="redirect_uri" value="#Google.redirect_uri#"> 
    <cfhttpparam type="formfield" name="grant_type" value="authorization_code"> 
</cfhttp> 
<cfdump var="#qry#"> 
+0

하지만 그렇게하면 json 리턴 코드로 이동하게됩니다. 대신 chttp 명령을 수행해야합니다. –

0

당신은 다음과 같이 뭔가를해야 :

그냥 https://www.googleapis.com/oauth2/v1/userinfo에 대한 요청이 매개 변수