發布/訂閱請求身份驗證作為服務(或通過服務密鑰)而不是 Auth0 臨時密鑰 (Pub/sub request authentication as a service (or by service key) instead of Auth0 temporary key)


問題描述

發布/訂閱請求身份驗證作為服務(或通過服務密鑰)而不是 Auth0 臨時密鑰 (Pub/sub request authentication as a service (or by service key) instead of Auth0 temporary key)

如果我添加從以下命令獲取的訪問令牌 </p>

POST https://pubsub.googleapis.com/v1/projects/[project_name]/topics/[topic_id]?key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content‑Type: application/json
</code></pre>

該令牌僅在 60 分鐘的有限時間內有效。因此,我必須每小時創建一個 access_token。

由於這是一個服務器到服務器的請求,我希望請求被授權更長時間,直到沒有任何外部干擾。

任何人都可以建議或指出任何錯誤。提前謝謝你

由於這是一個服務器到服務器的請求,我希望請求被授權更長的時間,直到沒有任何外部干擾。</strong></p>

任何人都可以提出建議或指出任何錯誤。提前謝謝你

由於這是一個服務器到服務器的請求,我希望請求被授權更長時間,直到沒有任何外部干擾。</strong></p>

任何人都可以提出建議或指出任何錯誤。提前謝謝你


參考解法

方法 1:

In your use case a production server to server communication when using a Google Cloud Platform client library. The best approach to authentication is to use a strategy called Application Default Credentials (ADC) to find your application's credentials.

If using a client library,the strategy checks for your credentials in the following order:

1) ADC checks to see if the environment variable GOOGLE_APPLICATION_CREDENTIALS is set. If the variable is set, ADC uses the service account file that the variable points to.

2) If the GOOGLE_APPLICATION_CREDENTIALS environment variable is not set, ADC uses the default service account that Compute Engine, Kubernetes Engine, Cloud Run, App Engine, and Cloud Functions provide, for applications that run on those services.

3) If ADC can't use either of the above credentials, an error occurs.

For a comprehensive explanation you should review the official documentation Setting Up Authentication for Server to Server Production Applications

(by nikhil sadalagiPaddy Popeye)

參考文件

  1. Pub/sub request authentication as a service (or by service key) instead of Auth0 temporary key (CC BY‑SA 2.5/3.0/4.0)

#authentication #google-cloud-pubsub #google-cloud-platform #google-authentication






相關問題

PHP Twitter OAuth - 我無法驗證我的帳戶 (PHP Twitter OAuth - I cannot authenticate my account)

如何設置 RIA 服務以使用現有的 ASP.Net 成員基礎 (How to setup RIA Services to use an existing ASP.Net membership base)

使用具有身份驗證的 URL 設置圖像-IOS SDK (Set Image With URL having authentication-IOS SDK)

支持 Facebook 的 Codeigniter 身份驗證庫 (Codeigniter Authentication library with Facebook support)

lighttpd:身份驗證後如何將端口(僅對本地主機可見)轉發到 WAN? (lighttpd: How to forward port (visible only to localhost) to WAN after authentication?)

Symfony 2.8 WebTestCase:無法創建登錄會話 (Symfony 2.8 WebTestCase: Cannot create logged-in session)

使用 facebook、twitter 等進行身份驗證。合而為一! (Authentication with facebook, twitter, etc.. all in one!)

默認情況下,ASP.NET 登錄控件是否使用 ReturnURL 進行重定向? (By default, does ASP.NET Login Control use the ReturnURL to redirect?)

發布/訂閱請求身份驗證作為服務(或通過服務密鑰)而不是 Auth0 臨時密鑰 (Pub/sub request authentication as a service (or by service key) instead of Auth0 temporary key)

通過 Nginx 進行 Haproxy 身份驗證 (Haproxy authentication through Nginx)

Django login() 身份驗證總是返回 None (Django login() authenticate always returns None)

laravel 微風 Multi Auth - 具有兩個不同註冊的 Admin Guard (laravel breeze Multi Auth - Admin Guard with two diffirent registration)







留言討論