Decipher Posted April 22, 2013 Share Posted April 22, 2013 I keep getting the Error=BadAuthentication response. expandcollapse popup#include-once #include "WinHTTP.au3" ;Reference = https://developers.google.com/accounts/docs/AuthForInstalledApps#AuthProcess ; GrandCentral or Google Voice as most know it isn't listed as a service VIA 0Auth2.0 $sReply = _GoogleClientLogin("anon@gmail.com", "password", "grandcentral", "autoIt") MsgBox(0, "", $sReply) ; Error=BadAuthentication Func _GoogleClientLogin($sUsername, $sPassword, $sService, $sSource) Local Const $sUSER_AGENT = 'Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20130419 Firefox/23.0' Local Const $sSERVER_NAME = 'www.google.com' Local Const $sOBJECT_NAME = '/accounts/ClientLogin' Local Const $sREFERRER = 'https://www.google.com' Local Const $sCONTENT_TYPE = 'Content-Type: application/x-www-form-urlencoded' $sLoginData = '' & _ 'Email=' & __WinHttpURLEncode($sUsername) & _ '&Passwd=' & __WinHttpURLEncode($sPassword) & _ '&service=' & __WinHttpURLEncode($sService) & _ '&source=' & __WinHttpURLEncode($sSource) ConsoleWrite('!>(AuthString)' & @TAB & $sLoginData & @CRLF) $hOpen = _WinHttpOpen($sUSER_AGENT) $hConnect = _WinHttpConnect($hOpen, $sSERVER_NAME, $INTERNET_DEFAULT_HTTPS_PORT) $hRequest=_WinHttpOpenRequest($hConnect, Default, $sOBJECT_NAME, Default, $sREFERRER, '', $WINHTTP_FLAG_SECURE) _WinHttpAddRequestHeaders($hRequest, $sCONTENT_TYPE) ;_WinHttpAddRequestHeaders($hRequest, 'Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5') ;_WinHttpAddRequestHeaders($hRequest, 'Accept-Charset: utf-8;q=0.7') _WinHttpAddRequestHeaders($hRequest, $sLoginData) ; <-- Append Login Data to Request Header _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) $sResponse = _WinHttpQueryHeaders($hRequest) $sResponse &= @CRLF & _WinHttpReadData($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $sResponse EndFunc Spoiler Link to comment Share on other sites More sharing options...
Decipher Posted April 22, 2013 Author Share Posted April 22, 2013 I tried using the WinHTTP object but it returns the same as the original function. Func _AlternativeMethod($sUsername, $sPassword, $sService, $sSource) $sLoginData = '' & _ 'accountType=HOSTED_OR_GOOGLE' & _ '&Email=' & __WinHttpURLEncode($sUsername) & _ '&Passwd=' & __WinHttpURLEncode($sPassword) & _ '&service=' & __WinHttpURLEncode($sService) & _ '&source=' & __WinHttpURLEncode($sSource) $oWinHttpReq = ObjCreate('WinHttp.WinHttpRequest.5.1') $oWinHttpReq.Open('POST', 'https://www.google.com/accounts/ClientLogin', false) $oWinHttpReq.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oWinHttpReq.Send($sLoginData) $sResponse = $oWinHttpReq.ResponseText Return $sResponse EndFunc Spoiler Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now