0
.Net (VB.Net) 용 Google Prediction API를 실행하려고하는데 몇 가지 문제가 있습니다. 누군가 서비스 계정 키 인증을 사용하는 코드 예가 있습니까?DotNet Google API 인증 문제
내 코드 :
Google.Apis.Requests.RequestError
Login Required [401]
Errors [
Message[Login Required] Location[Authorization - header] Reason[required] Domain[global]
]
그래서, 서비스 계정 키를 생성 구글 콘솔에서 내가 JSON의 다운로드를했다 :
Dim myService As New PredictionService()
Dim myInput As New Data.Input()
Dim myInputData As New Data.Input.InputData()
Dim myListParameters As New List(Of Object)
myListParameters.Add("myInfo")
myInputData.CsvInstance = myListParameters
myInput.InputValue = myInputData
Dim myRequest As TrainedmodelsResource.PredictRequest = _
myService.Trainedmodels.Predict(myInput, "myProject", "myModel")
myRequest.OauthToken = "How can I get the OauthToken?"
myRequest.Key = "My API Key"
Dim myResponse = myRequest.Execute()
나는 위의 코드를 실행 나는 응답을 파일을 만들고 코드를 실행하여 authToken을 생성하십시오.
Dim prediction As New PredictionService
Dim service = ServiceAccountCredential.FromServiceAccountData(_
New StreamReader("the path of jsonFile").BaseStream)
Dim auth As String = Await service.GetAccessTokenForRequestAsync()
이 코드를 실행하면 get e 오류 : "invalid_scope", "빈 또는 누락 된 범위가 허용되지 않습니다.", Uri : ""
내 변수 서비스의 Scope 속성이 비어 있고 ReadOnly입니다. 그래서 나는 어떻게 진행해야할지 모른다.
나를 도와 줄 수 있습니까?
감사합니다.