<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 28.3.1 客戶端 為了將web-app放入一個OAuth2客戶端,你只需注解`@EnableOAuth2Client`,Spring Boot會創建`OAuth2ClientContext`和`OAuth2ProtectedResourceDetails`,這些是創建`OAuth2RestOperations`必需的。Spring Boot不會自動創建該bean,但你自己創建也不費力: ```java @Bean public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext, OAuth2ProtectedResourceDetails details) { return new OAuth2RestTemplate(details, oauth2ClientContext); } ``` **注** 你可能想添加一個限定名(qualifier),因為應用中可能定義多個`RestTemplate`。 該配置使用`security.oauth2.client.*`作為證書(跟授權服務器使用的相同),此外,它也需要知道授權服務器中認證和token的URIs,例如: ```yml security: oauth2: client: clientId: bd1c0a783ccdd1c9b9e4 clientSecret: 1a9030fbca47a5b2c28e92f19050bb77824b5ad1 accessTokenUri: https://github.com/login/oauth/access_token userAuthorizationUri: https://github.com/login/oauth/authorize clientAuthenticationScheme: form ``` 具有該配置的應用在使用`OAuth2RestTemplate`時會重定向到GitHub以完成授權,如果已經登陸GitHub,你甚至不會注意到它已經授權過了。那些特殊的憑證(credentials)只在應用運行于8080端口時有效(為了更靈活,在GitHub或其他提供商上注冊自己的客戶端app)。 在客戶端獲取access token時,你可以設置`security.oauth2.client.scope`(逗號分隔或一個YAML數組)來限制它請求的作用域(scope)。作用域默認是空的,默認值取決于授權服務器,通常依賴于它擁有的客戶端在注冊時的設置。 **注** 對`security.oauth2.client.client-authentication-scheme`也有設置,默認為"header"(如果你的OAuth2提供商不喜歡header認證,例如Github,你可能需要將它設置為“form”)。實際上,`security.oauth2.client.*`屬性綁定到一個`AuthorizationCodeResourceDetails`實例,所以它的所有屬性都可以指定。 **注** 在一個非web應用中,你仍舊可以創建一個`OAuth2RestOperations`,并且跟`security.oauth2.client.*`配置關聯。在這種情況下,它是一個“client credentials token grant”,如果你使用它的話就需要獲取(此處不需要注解`@EnableOAuth2Client`或`@EnableOAuth2Sso`)。為了防止基礎設施定義,只需要將`security.oauth2.client.client-id`從配置中移除(或將它設為空字符串)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看