use external application to get Identity Server token / cookie












5














Does anyone have experience connecting to Identity Server in 9.1 to get an authentication token / cookie of sorts?



I'm trying to do this in PowerShell.



In Commerce 9.x, you could connect directly to IdentityServer's /connect/token endpoint to obtain a token that you could then use to send requests to the engine.



In XP 9.1, I'm trying to make calls to various /sitecore pages using PowerShell to help "warm-up" the instance. In the past I was shown how to access /sitecore/login in order to populate a $session object. What does that look like now with IdentityServer?










share|improve this question



























    5














    Does anyone have experience connecting to Identity Server in 9.1 to get an authentication token / cookie of sorts?



    I'm trying to do this in PowerShell.



    In Commerce 9.x, you could connect directly to IdentityServer's /connect/token endpoint to obtain a token that you could then use to send requests to the engine.



    In XP 9.1, I'm trying to make calls to various /sitecore pages using PowerShell to help "warm-up" the instance. In the past I was shown how to access /sitecore/login in order to populate a $session object. What does that look like now with IdentityServer?










    share|improve this question

























      5












      5








      5







      Does anyone have experience connecting to Identity Server in 9.1 to get an authentication token / cookie of sorts?



      I'm trying to do this in PowerShell.



      In Commerce 9.x, you could connect directly to IdentityServer's /connect/token endpoint to obtain a token that you could then use to send requests to the engine.



      In XP 9.1, I'm trying to make calls to various /sitecore pages using PowerShell to help "warm-up" the instance. In the past I was shown how to access /sitecore/login in order to populate a $session object. What does that look like now with IdentityServer?










      share|improve this question













      Does anyone have experience connecting to Identity Server in 9.1 to get an authentication token / cookie of sorts?



      I'm trying to do this in PowerShell.



      In Commerce 9.x, you could connect directly to IdentityServer's /connect/token endpoint to obtain a token that you could then use to send requests to the engine.



      In XP 9.1, I'm trying to make calls to various /sitecore pages using PowerShell to help "warm-up" the instance. In the past I was shown how to access /sitecore/login in order to populate a $session object. What does that look like now with IdentityServer?







      identity-server






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      jflsitecore

      1116




      1116






















          1 Answer
          1






          active

          oldest

          votes


















          3














          With some serious Googling, and with the help of the Community and this gist I was able to successfully get a token from Sitecore 9.1's Identity Server.



          First, you need to add a new Client to the Sitecore.IdentityServer.Host.xml file (ConfigproductionSitecore.IdentityServer.Host.xml).



          I dug up more details on the PasswordClient and created my own version by copying PasswordClient as a template and called it PostmanClient giving it a client id of "postman-api".



           <Clients>
          <DefaultClient>
          <AllowedCorsOrigins>
          <AllowedCorsOriginsGroup1>https://habitathome.dev.local|https://habitathomebasic.dev.local</AllowedCorsOriginsGroup1>
          </AllowedCorsOrigins>
          </DefaultClient>
          <PasswordClient>
          <ClientSecrets>
          <ClientSecret1>ClientSecret</ClientSecret1>
          </ClientSecrets>
          </PasswordClient>
          <PostmanClient>
          <ClientId>postman-api</ClientId>
          <ClientName>postman-api</ClientName>
          <AccessTokenType>0</AccessTokenType>
          <AllowOfflineAccess>true</AllowOfflineAccess>
          <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
          <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
          <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
          <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
          <RequireConsent>false</RequireConsent>
          <RequireClientSecret>true</RequireClientSecret>
          <AllowedGrantTypes>
          <AllowedGrantType1>password</AllowedGrantType1>
          </AllowedGrantTypes>
          <AllowedCorsOrigins>
          </AllowedCorsOrigins>
          <AllowedScopes>
          <AllowedScope1>openid</AllowedScope1>
          <AllowedScope2>sitecore.profile</AllowedScope2>
          <AllowedScope3>sitecore.profile.api</AllowedScope3>
          </AllowedScopes>
          <ClientSecrets>
          <ClientSecret1>ClientSecret</ClientSecret1>
          </ClientSecrets>
          <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
          </PostmanClient>
          </Clients>


          Once that was done (and I restarted identity server) I was able to use the gist sample and provide values relevant to my newly added client:



          $identityserverUrl = "https://<url-to-your-identityserver>"
          $tokenendpointurl = $identityserverUrl + "/connect/token"
          $granttype = "password" # client_credentials / password
          $client_id = "postman-api"
          $client_secret = "ClientSecret"
          $username = "sitecoreadmin"
          $password = "superStrongPassword"
          $scope = "openid"


          We are then left with an access_token which can be used to connect to Sitecore.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "664"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15853%2fuse-external-application-to-get-identity-server-token-cookie%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            With some serious Googling, and with the help of the Community and this gist I was able to successfully get a token from Sitecore 9.1's Identity Server.



            First, you need to add a new Client to the Sitecore.IdentityServer.Host.xml file (ConfigproductionSitecore.IdentityServer.Host.xml).



            I dug up more details on the PasswordClient and created my own version by copying PasswordClient as a template and called it PostmanClient giving it a client id of "postman-api".



             <Clients>
            <DefaultClient>
            <AllowedCorsOrigins>
            <AllowedCorsOriginsGroup1>https://habitathome.dev.local|https://habitathomebasic.dev.local</AllowedCorsOriginsGroup1>
            </AllowedCorsOrigins>
            </DefaultClient>
            <PasswordClient>
            <ClientSecrets>
            <ClientSecret1>ClientSecret</ClientSecret1>
            </ClientSecrets>
            </PasswordClient>
            <PostmanClient>
            <ClientId>postman-api</ClientId>
            <ClientName>postman-api</ClientName>
            <AccessTokenType>0</AccessTokenType>
            <AllowOfflineAccess>true</AllowOfflineAccess>
            <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
            <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
            <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
            <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
            <RequireConsent>false</RequireConsent>
            <RequireClientSecret>true</RequireClientSecret>
            <AllowedGrantTypes>
            <AllowedGrantType1>password</AllowedGrantType1>
            </AllowedGrantTypes>
            <AllowedCorsOrigins>
            </AllowedCorsOrigins>
            <AllowedScopes>
            <AllowedScope1>openid</AllowedScope1>
            <AllowedScope2>sitecore.profile</AllowedScope2>
            <AllowedScope3>sitecore.profile.api</AllowedScope3>
            </AllowedScopes>
            <ClientSecrets>
            <ClientSecret1>ClientSecret</ClientSecret1>
            </ClientSecrets>
            <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
            </PostmanClient>
            </Clients>


            Once that was done (and I restarted identity server) I was able to use the gist sample and provide values relevant to my newly added client:



            $identityserverUrl = "https://<url-to-your-identityserver>"
            $tokenendpointurl = $identityserverUrl + "/connect/token"
            $granttype = "password" # client_credentials / password
            $client_id = "postman-api"
            $client_secret = "ClientSecret"
            $username = "sitecoreadmin"
            $password = "superStrongPassword"
            $scope = "openid"


            We are then left with an access_token which can be used to connect to Sitecore.






            share|improve this answer


























              3














              With some serious Googling, and with the help of the Community and this gist I was able to successfully get a token from Sitecore 9.1's Identity Server.



              First, you need to add a new Client to the Sitecore.IdentityServer.Host.xml file (ConfigproductionSitecore.IdentityServer.Host.xml).



              I dug up more details on the PasswordClient and created my own version by copying PasswordClient as a template and called it PostmanClient giving it a client id of "postman-api".



               <Clients>
              <DefaultClient>
              <AllowedCorsOrigins>
              <AllowedCorsOriginsGroup1>https://habitathome.dev.local|https://habitathomebasic.dev.local</AllowedCorsOriginsGroup1>
              </AllowedCorsOrigins>
              </DefaultClient>
              <PasswordClient>
              <ClientSecrets>
              <ClientSecret1>ClientSecret</ClientSecret1>
              </ClientSecrets>
              </PasswordClient>
              <PostmanClient>
              <ClientId>postman-api</ClientId>
              <ClientName>postman-api</ClientName>
              <AccessTokenType>0</AccessTokenType>
              <AllowOfflineAccess>true</AllowOfflineAccess>
              <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
              <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
              <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
              <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
              <RequireConsent>false</RequireConsent>
              <RequireClientSecret>true</RequireClientSecret>
              <AllowedGrantTypes>
              <AllowedGrantType1>password</AllowedGrantType1>
              </AllowedGrantTypes>
              <AllowedCorsOrigins>
              </AllowedCorsOrigins>
              <AllowedScopes>
              <AllowedScope1>openid</AllowedScope1>
              <AllowedScope2>sitecore.profile</AllowedScope2>
              <AllowedScope3>sitecore.profile.api</AllowedScope3>
              </AllowedScopes>
              <ClientSecrets>
              <ClientSecret1>ClientSecret</ClientSecret1>
              </ClientSecrets>
              <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
              </PostmanClient>
              </Clients>


              Once that was done (and I restarted identity server) I was able to use the gist sample and provide values relevant to my newly added client:



              $identityserverUrl = "https://<url-to-your-identityserver>"
              $tokenendpointurl = $identityserverUrl + "/connect/token"
              $granttype = "password" # client_credentials / password
              $client_id = "postman-api"
              $client_secret = "ClientSecret"
              $username = "sitecoreadmin"
              $password = "superStrongPassword"
              $scope = "openid"


              We are then left with an access_token which can be used to connect to Sitecore.






              share|improve this answer
























                3












                3








                3






                With some serious Googling, and with the help of the Community and this gist I was able to successfully get a token from Sitecore 9.1's Identity Server.



                First, you need to add a new Client to the Sitecore.IdentityServer.Host.xml file (ConfigproductionSitecore.IdentityServer.Host.xml).



                I dug up more details on the PasswordClient and created my own version by copying PasswordClient as a template and called it PostmanClient giving it a client id of "postman-api".



                 <Clients>
                <DefaultClient>
                <AllowedCorsOrigins>
                <AllowedCorsOriginsGroup1>https://habitathome.dev.local|https://habitathomebasic.dev.local</AllowedCorsOriginsGroup1>
                </AllowedCorsOrigins>
                </DefaultClient>
                <PasswordClient>
                <ClientSecrets>
                <ClientSecret1>ClientSecret</ClientSecret1>
                </ClientSecrets>
                </PasswordClient>
                <PostmanClient>
                <ClientId>postman-api</ClientId>
                <ClientName>postman-api</ClientName>
                <AccessTokenType>0</AccessTokenType>
                <AllowOfflineAccess>true</AllowOfflineAccess>
                <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
                <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
                <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
                <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
                <RequireConsent>false</RequireConsent>
                <RequireClientSecret>true</RequireClientSecret>
                <AllowedGrantTypes>
                <AllowedGrantType1>password</AllowedGrantType1>
                </AllowedGrantTypes>
                <AllowedCorsOrigins>
                </AllowedCorsOrigins>
                <AllowedScopes>
                <AllowedScope1>openid</AllowedScope1>
                <AllowedScope2>sitecore.profile</AllowedScope2>
                <AllowedScope3>sitecore.profile.api</AllowedScope3>
                </AllowedScopes>
                <ClientSecrets>
                <ClientSecret1>ClientSecret</ClientSecret1>
                </ClientSecrets>
                <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
                </PostmanClient>
                </Clients>


                Once that was done (and I restarted identity server) I was able to use the gist sample and provide values relevant to my newly added client:



                $identityserverUrl = "https://<url-to-your-identityserver>"
                $tokenendpointurl = $identityserverUrl + "/connect/token"
                $granttype = "password" # client_credentials / password
                $client_id = "postman-api"
                $client_secret = "ClientSecret"
                $username = "sitecoreadmin"
                $password = "superStrongPassword"
                $scope = "openid"


                We are then left with an access_token which can be used to connect to Sitecore.






                share|improve this answer












                With some serious Googling, and with the help of the Community and this gist I was able to successfully get a token from Sitecore 9.1's Identity Server.



                First, you need to add a new Client to the Sitecore.IdentityServer.Host.xml file (ConfigproductionSitecore.IdentityServer.Host.xml).



                I dug up more details on the PasswordClient and created my own version by copying PasswordClient as a template and called it PostmanClient giving it a client id of "postman-api".



                 <Clients>
                <DefaultClient>
                <AllowedCorsOrigins>
                <AllowedCorsOriginsGroup1>https://habitathome.dev.local|https://habitathomebasic.dev.local</AllowedCorsOriginsGroup1>
                </AllowedCorsOrigins>
                </DefaultClient>
                <PasswordClient>
                <ClientSecrets>
                <ClientSecret1>ClientSecret</ClientSecret1>
                </ClientSecrets>
                </PasswordClient>
                <PostmanClient>
                <ClientId>postman-api</ClientId>
                <ClientName>postman-api</ClientName>
                <AccessTokenType>0</AccessTokenType>
                <AllowOfflineAccess>true</AllowOfflineAccess>
                <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
                <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
                <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
                <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
                <RequireConsent>false</RequireConsent>
                <RequireClientSecret>true</RequireClientSecret>
                <AllowedGrantTypes>
                <AllowedGrantType1>password</AllowedGrantType1>
                </AllowedGrantTypes>
                <AllowedCorsOrigins>
                </AllowedCorsOrigins>
                <AllowedScopes>
                <AllowedScope1>openid</AllowedScope1>
                <AllowedScope2>sitecore.profile</AllowedScope2>
                <AllowedScope3>sitecore.profile.api</AllowedScope3>
                </AllowedScopes>
                <ClientSecrets>
                <ClientSecret1>ClientSecret</ClientSecret1>
                </ClientSecrets>
                <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
                </PostmanClient>
                </Clients>


                Once that was done (and I restarted identity server) I was able to use the gist sample and provide values relevant to my newly added client:



                $identityserverUrl = "https://<url-to-your-identityserver>"
                $tokenendpointurl = $identityserverUrl + "/connect/token"
                $granttype = "password" # client_credentials / password
                $client_id = "postman-api"
                $client_secret = "ClientSecret"
                $username = "sitecoreadmin"
                $password = "superStrongPassword"
                $scope = "openid"


                We are then left with an access_token which can be used to connect to Sitecore.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                jflsitecore

                1116




                1116






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Sitecore Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15853%2fuse-external-application-to-get-identity-server-token-cookie%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Eastern Orthodox Church

                    Zagreb

                    Understanding the information contained in the Deep Space Network XML data?