2012-04-12 8 views
1

Google의 "서비스 계정"인증을 위해 oath2 사양을 사용하여 인증 할 json 요청을 작성하려고합니다. Google의 설명서 here을 사용하고 있습니다. 그것은 JWT를 사용하고 있습니다. C#을 사용하여이 작업을 수행하는 방법에 대한 정보는 많지 않습니다. 이것은 내가 사용하고있는 RAW json 요청이지만 Google에서 얻을 수있는 유일한 응답은 "invalid_request"입니다."Google 서비스"에 대한 OAuth2 인증이 "invalid_request"를 반환합니다

POST https://accounts.google.com/o/oauth2/token HTTP/1.1 
Content-Type: application/x-www-form-urlencoded 
Host: accounts.google.com 
Content-Length: 457 
Expect: 100-continue 
Connection: Keep-Alive 

{ 
    "grant_type": "assertion", 
    "assertion_type": "http://oauth.net/grant_type/jwt/1.0/bearer", 
    "assertion": "JWT (including signature)" 
} 

어떤 일이 벌어 질 수 있는지에 대한 아이디어가 있습니까? 설정된 간격으로 Google 위도 위치를 ping하는 Windows 서비스를 만들려고합니까? 이 후프를 뛰어 넘지 않고 API에 액세스 할 수있는 다른 방법이 있습니까? 감사!

+0

분명히 내가 대체하고있다 "JWT (포함 서명)"내 – aceinthehole

+0

토큰 보이지 않는 계산이 자신의 "application/x-www-form-urlencoded"에 부합하는 유사 콘텐츠를 제공합니다. 저 사람이야. – spender

답변

1

문서는 상대적으로 명확하므로 URL로 인코딩 된 문자열을 POST해야합니다. 대신 JSON, 대신 포스트 응용 프로그램/x-www-form-urlencoded로 데이터를 게시하는 시도의 :와

var invariantPart = "grant_type=assertion&" + 
    "assertion_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fjwt%2F1.0%2Fbearer&" + 
    "assertion="; 
var fullPostData = invariantPart + Uri.EscapeDataString(myCalculatedAssertion); 
//POST fullPostData to google