문제

Google-API-NodeJS-Client를 성공적으로 삽입 할 수 있습니까?

무엇이든간에, 제네릭 400 "유효하지 않은 값"오류가 발생했지만 API 탐색기 가 작동하지 않습니다.

누락 된 Data-RequestVisbleActions 매개 변수 때문일 것입니까? OAuth 액세스를 처리하기 위해 Passport.js의 require('passport-google-oauth').OAuth2Strategy를 사용하고 있으며 해당 부분이 정상적으로 작동하지만,이 기능이 클라이언트의 형태로부터 유래하지 않기 때문에 OAuth 요청 흐름에 RequestVIsibleActions를 통합하는 방법은 모릅니다.

여기에 내가하려는 것의 스 니펫 (최신 버전의 googleapis, v1.0.2를 사용하여) :

var google = require('googleapis')
var auth = new google.auth.OAuth2()
auth.setCredentials({
  'access_token': user.token
})

google.plus('v1').moments.insert({
  collection: 'vault',
  userId: 'me',
  debug: true,
  resource: {
    type: "http://schemas.google.com/AddActivity",
    target: {
      type: "http://schema.org/CreativeWork",
      url: "...omitted...",
      image: "...omitted...",
      description: "test",
      name: "test"
    }
  },
  auth: auth
}, function (err, response) {
  if (err) {
    console.error(err)
    res.send(err.code, err)
  } else {
    console.log(response)
    res.send(200)
  }
})
.

Ref 1 <. / A> (googleapis의 이전 버전 구형 버전)

Ref 2 (데이터-requestvisbleActions의 사용이있는 클라이언트 측) 더 명백한)

도움이 되었습니까?

해결책

추적 할 때, OAuth 엔드 포인트를 호출하는 URL의 일부로 request_visible_actions 매개 변수가 필요합니다.

현재 Passport-Google-OAuth 가이 매개 변수를 지원하지 않는 것처럼 보입니다. 개방 된 문제점 및 요청을 몇 개로 판단하면 저자가 요청에 응답 할 것이라는 것이 명확하지 않습니다. 가능한 두 가지 옵션이 있습니다.

  1. google-api-nodejs-client

  2. 에 포함 된 OAuth 지원 사용으로 전환

  3. 여권 - Google-OAuth 코드를 패치합니다. (아마도 다른 사람에게 유용 할 희망으로 끌어 오기 요청을 제출할 수 있습니다.)

  4. 문제의 여권 모듈을 사용하지 않으므로이 작업을 테스트 할 수 없지만 GitHub 저장소를 기반으로 lib / passport-google-oauth / oauth2.js 후 136 행 및 return 문 이전 :

    if (options.requestVisibleActions) {
      // Space separated list of allowed app actions
      // as documented at:
      //  https://developers.google.com/+/web/app-activities/#writing_an_app_activity_using_the_google_apis_client_libraries
      //  https://developers.google.com/+/api/moment-types/
      params['request_visible_actions'] = options.requestVisibleActions;
    }
    
    .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top