.NETのGoogle予測APIサービス認証
-
11-12-2019 - |
質問
Googleの予測APIにアクセスするであろう.NETサービスアプリケーションを構築しようとしています。
このアプリケーションはサービス(ユーザーの操作なし)であるため、Google APIを自動的に認証する方法が知りたい(ログインするブラウザを開き、「Authorize」を押す)ことができます。 。
試したもの:
-
いくつかの.NET Google APIサンプルの一部を実行しました - それらはすべてブラウザを開くこの認証方式を必要としており、ユーザーがクリックする必要があるように見えます(これはネイティブアプリケーションクライアント認証と呼ばれ、私は信じています)。
-
この時点で、私はPythonのサンプルを行くことができるようになり、それを.NETで再書き直すか、鉄のPythonでそれを使用することができることを願っています。
誰かが前にこの種の問題を持っていたら、そして決議は何ですか。 OAuth2サービス認証が可能でない(今のところ).NET。
解決
I've written a sample app (in Python & Java, sorry not available in C#) which authenticates once, stores the OAuth credentials and related data on the server (Google App Engine) and from that point forward reuses those shared credentials, refreshing the access token when needed, without requiring end users to see the OAuth allow/deny dialog, or any other aspect of OAuth.
This still requires the application administrator to execute the OAuth dialog but that's a one-time event. If for some reason you want to reset the stored server credentials, the initialization step can be re-executed on demand via a special URL, however, this reset function is protected so that only the application administrator can make that request, not an end user.