質問

は、Google-API-NodeJS-Clientを瞬間を正常に挿入させることができましたか?

私が試してみるものは何でも、汎用400 "無効な値"エラーが発生しますが、 API Explorer も機能しません。

欠落しているデータ要求isibleOctionsパラメータのためになりますか? OAuthアクセスを処理するためにpassport.jsのrequire('passport-google-oauth').OAuth2Strategyを使用しています。その部分は正常に機能していますが、これは概念的にクライアントサイドフォームから発生していないため、OAuthリクエストフローに組み込む方法はわかりません。

これは私がやろうとしていることの範囲の範囲です(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の古いバージョンのWRT)

Ref 2 (データ要求isibleactionの使用が行われるクライアント側)もっと明白な)

役に立ちましたか?

解決

推測したときに、OAuthエンドポイントを呼び出すURLの一部としてrequest_visible_actionsパラメータが必要です。

現在のバージョンのpassport-google-oauthがこのパラメータをサポートしていないようです。オープンの問題とプル要求のいくつかによって判断すると、作者がそれを追加する要求に応答することは明らかではありません。 2つのオプションが2つあります。

  1. Google-API-NodeJS-Client

  2. に含まれているOAuthサポートの使用に切り替えます。

  3. Passport-Google-OAuthコードをパッチします。 (そしておそらくそれは他の人にとって有用な希望のためにプル要求を提出する可能性があります。)

  4. Passport.jsまたはPassportモジュールを使用しないので、これをテストできませんが、Githubリポジトリに基づいて、 lib / passport-google-oauth / oauth2.js 136行目以前:

    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