0

Google은 Provisioning API 용 XML 코드 블록을 생성 한 다음 VBScript를 사용하여 POST를 수행하여 Google Apps 계정을 만들고 관리하고 있습니다. 이제 GoogleApps는 새로운 관리 SDK로 전환해야하며, 새로운 시스템과 유사한 작업을 수행 할 수있는 방법을 이해하지 못하고 있습니다.GoogleAppProvisioning API에서 새 SDK로 변환

' Create XML Record that will be sent to GoogleApps 
    strXMLRecord = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & _ 
       "?>" & vbCRLF 
    strXMLRecord = strXMLRecord & "<atom:entry xmlns:atom=" & Chr(34) & "http://www.w3.org/2005/Atom" & Chr(34) & _ 
       vbCRLF 
    strXMLRecord = strXMLRecord & " xmlns:apps=" & Chr(34) & "http://schemas.google.com/apps/2006" & Chr(34) & _ 
       ">" & vbCRLF 
    strXMLRecord = strXMLRecord & " <atom:category scheme=" & Chr(34) & "http://schemas.google.com/g/2005#kind" & _ 
       Chr(34) & vbCRLF 
    strXMLRecord = strXMLRecord & "  term=" & Chr(34) & "http://schemas.google.com/apps/2006#user" & Chr(34) & _ 
       "/>" & vbCRLF 
    strXMLRecord = strXMLRecord & " <apps:login userName=" & Chr(34) & strCGAAUsername & Chr(34) & vbCRLF 
    strXMLRecord = strXMLRecord & "  password=" & Chr(34) & strCGAAPwd & Chr(34) & vbCRLF 
    strXMLRecord = strXMLRecord & "  changePasswordAtNextLogin=" & Chr(34) & "true" & Chr(34) & vbCRLF 
    strXMLRecord = strXMLRecord & "  suspended=" & Chr(34) & "false" & Chr(34) & "/>" & vbCRLF 
    ' The following line is just so we have the syntax if we need to set quotas 
    '*****strXMLRecord = strXMLRecord & " <apps:quota limit=" & Chr(34) & "2048" & Chr(34) & "/>" & vbCRLF***** 
    strXMLRecord = strXMLRecord & " <apps:name familyName=" & Chr(34) & strCGAALastName & Chr(34) & " givenName=" & _ 
       Chr(34) & strCGAAFirstName & Chr(34) & "/>" 
    strXMLRecord = strXMLRecord & vbCRLF & "</atom:entry>" & vbCRLF 
    ' Create XML object, set headers, and send to GoogleApps  
    Set objXMLHTTP = CreateObject("Microsoft.XmlHttp") 
    objXMLHTTP.open "POST", "https://apps-apis.google.com/a/feeds/company.com/user/2.0", FALSE 
    objXMLHTTP.setRequestHeader "Content-type", "application/atom+xml" 
    objXMLHTTP.setRequestHeader "Authorization", "GoogleLogin auth=" & strGAAuthToken 
    objXMLHTTP.send strXMLRecord 
    If Err.Number <> 0 Then 
    WScript.Echo "ERROR: unable to XMLHTTP.send for GoogleApps acct creation" 
    CreateGAAccount = False 
    WScript.Quit(1) 
    End If 
    ' Get response from GoogleApps 
    strResponseText = objXMLHTTP.responseText 
    If Err.Number <> 0 Then 
    WScript.Echo "ERROR: unable to get objXMLHTTP.responseText during GoogleApps acct creation" 
    CreateGAAccount = False 
    WScript.Quit(1) 
    End If 
    ' If response reports an error exit function returning False 
    If InStr(Lcase(strResponseText), "errorcode=") <> 0 Then 
    WScript.Echo "ERROR: unable to create GoogleApps account" 
    CreateGAAccount = False 
    WScript.Quit(1) 
    End If 
    ' Log GoogleApps account information returned from creation 
    WScript.Echo "GoogleApp account created for: " & strCGAAUsername 

그것은이다 : 우리가 다음 계정을 만드는 데 사용하는 코드의 샘플 여기

' Create and send XML message to GoogleApps requesting Authentication Token 
Set objXMLHTTP = CreateObject("Microsoft.XmlHttp") 
objXMLHTTP.open "POST", "https://www.google.com/accounts/ClientLogin", FALSE 
objXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
objXMLHTTP.send "&Email=Administrator%40company%2Ecom%2Eedu&[email protected]&accountType=HOSTED&service=apps" 
If Err.Number <> 0 Then 
    WScript.Echo "Error: send request for GoogleApp Authentication Token failed" 
    WScript.Quit(1) 
End If 
' Get response from GoogleApps 
strGGAATAuthToken = objXMLHTTP.responseText 
If Err.Number <> 0 Then 
    WScript.Echo "ERROR: Getting GoogleApp Authentication Token (XMLHTTP.responseText) " 
    WScript.Quit(1) 
End If 
' Check for known errors in response text 
If LCase(Left(strGGAATAuthToken, 6)) = "error=" Then 
    WScript.Echo "ERROR: GoogleApp replied with Error when asking for Authentication Token" 
    WScript.Quit(1) 
Else 
    ' Extract and return Authentication Token from response text 
    strGGAATToken = Mid(strGGAATAuthToken, InStr(strGGAATAuthToken, "Auth=") + 5) 
    GetGAAuthToken = True 
End If 

됩니다 : 여기

우리가 먼저 인증 토큰을 얻기 위해 사용하는 코드의 예입니다 아마도 분명하지만, 리눅스가 아닌 Windows 배경을 가지고 있습니다. 스크립팅을했는데 실제 프로그래밍은하지 않았습니다. (Java 및/또는 다른 웹 프로그래밍 경험이 전혀 없습니다.)

어떤 도움을 주셔서 감사합니다!

답변

0

Admin SDK를 사용하는 단계는 매우 유사합니다. https://developers.google.com/oauthplayground/

지금 새 사용자를 만들 디렉토리 API를 호출 할 수 있습니다 인증 된 후에 : 당신이 인증을 얻을 것이다 첫째, 이제 구글은 여기 OAuth를 어떻게 작동하는지 테스트 할 수 https://developers.google.com/accounts/docs/OAuth2 에 대한 설명서를 찾을 수의 Oauth 여기에 2를 사용 . 다음은 삽입 방법과 관련된 문서입니다. https://developers.google.com/admin-sdk/directory/v1/reference/users/insert

Doc에서 볼 수 있듯이 동일한 매개 변수 (이름, 비밀번호 등)가 전송되지만 이제는 xml로 형식이 지정되지 않습니다. 매개 변수는 json으로 형식이 지정됩니다 (여기에 json 형식에 대한 약간의 정보가 있습니다.)

저는 정보가 풍부하다는 것을 알고 있습니다.