從 AuthURL 和 ClientID 獲取 OAuth2.0 Bearer Token (Get OAuth2.0 Bearer Token from AuthURL and ClientID)


問題描述

從 AuthURL 和 ClientID 獲取 OAuth2.0 Bearer Token (Get OAuth2.0 Bearer Token from AuthURL and ClientID)

在 Postman 中,我可以使用

  1. Callback URL
  2. Auth URL
  3. Client ID
  4. 生成承載令牌ol>

    如何使用 C# 代碼執行相同操作?

    這是我正在運行的代碼,但響應正文沒有不記名令牌。

    var client = new RestClient("AuthURL"); 
    var requestToken = new RestRequest(Method.POST); 
    requestToken.AddHeader("cache‑control", "no‑cache"); 
    requestToken.AddHeader("content‑type", "application/x‑www‑form‑urlencoded"); 
    requestToken.AddParameter("application/x‑www‑form‑urlencoded", "grant_type=client_credentials&client_id=123", ParameterType.RequestBody); 
    IRestResponse response = client.Execute(requestToken);
    
    string res = response.Content;
    

    參考解法

    方法 1:

    where is your username and password?

    var client = new RestClient("http://example.com");
    client.Authenticator = new HttpBasicAuthenticator(userName, password);
    
    var request = new RestRequest("resource", Method.GET);
    client.Execute(request);
    

    might be a duplicate of this question RestSharp HttpBasicAuthentication ‑ example

    (by sreesh prakashFractal)

    參考文件

    1. Get OAuth2.0 Bearer Token from AuthURL and ClientID (CC BY‑SA 2.5/3.0/4.0)

#OAuth #REST #bearer-token #Postman #C#






相關問題

我在哪裡可以在谷歌上為 xoauth 註冊 Android 應用以獲取消費者密鑰和消費者秘密 (where can I register Android app on google for xoauth for consumer key and consumer secret)

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

dapatkan kontak aol menggunakan oauth api (get aol contacts using oauth api)

Otentikasi permanen Google Latitude API untuk akun tertentu (Google Latitude API permanent auth for specific account)

Перанакіраванне ад даччынага акна да бацькоўскага ў iframe з дапамогай javascript (OAuth) (Redirecting from child window to parent to a iframe using javascript (OAuth))

Linkedin 應用程序具有 OAuth 用戶令牌和 OAuth 用戶密鑰,它們會過期嗎? (Linkedin Application has OAuth User Token and OAuth User Secret, Do they Expire?)

jhipster oauth:如何通過 CURL 獲取令牌 (jhipster oauth : How can i get the token via CURL)

在 android (eclipse) 中集成 oAuth twitter 時清除共享首選項 (Clearing shared preferences in case of oAuth twitter integration in android (eclipse))

Spring Boot 2 Oauth 如何實現隱式代碼流 (Spring Boot 2 Oauth how to implement Implicit Code Flow)

ASP.NET Web App 的授權代碼流代碼示例 (Authorization Code Flow code examples for ASP.NET Web App)

從 AuthURL 和 ClientID 獲取 OAuth2.0 Bearer Token (Get OAuth2.0 Bearer Token from AuthURL and ClientID)

如何解決 Netsuite Restlets 中的 400 bad request 錯誤? (How to solve 400 bad request error in Netsuite Restlets?)







留言討論