Warm tip: This article is reproduced from serverfault.com, please click

Create Service Provider with Oauth2 with SOAP

发布于 2020-11-30 16:42:19

I am trying to create a SP via SOAP. The call for creating a SP is correct after which I try to configure Oauth2 via SOAP specifying oauthConsumerKey and oauthConsumerSecret like so

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://dto.oauth.identity.carbon.wso2.org/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:registerOAuthApplicationData>
         <xsd:application>
            <xsd1:OAuthVersion>OAuth-2.0</xsd1:OAuthVersion>
            <xsd1:applicationAccessTokenExpiryTime>3600</xsd1:applicationAccessTokenExpiryTime>
            <xsd1:applicationName>test</xsd1:applicationName>
            <xsd1:callbackUrl>regexp=(.*)/login/oauth2/code/wso2</xsd1:callbackUrl>
            <xsd1:grantTypes>refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer implicit password client_credentials iwa:ntlm authorization_code urn:ietf:params:oauth:grant-type:uma-ticket urn:ietf:params:oauth:grant-type:jwt-bearer</xsd1:grantTypes>
            <xsd1:oauthConsumerKey>gVWBVK0pdX4pg2Yk3fFbBjKe1aUa</xsd1:oauthConsumerKey>
            <xsd1:oauthConsumerSecret>CbfGJXhTYvb3i1BAfu5ijgUSXXYa</xsd1:oauthConsumerSecret>
            <xsd1:pkceMandatory>false</xsd1:pkceMandatory>
            <xsd1:pkceSupportPlain>true</xsd1:pkceSupportPlain>
            <xsd1:refreshTokenExpiryTime>86400</xsd1:refreshTokenExpiryTime>
            <xsd1:userAccessTokenExpiryTime>3600</xsd1:userAccessTokenExpiryTime>
         </xsd:application>
      </xsd:registerOAuthApplicationData>
   </soapenv:Body>
</soapenv:Envelope>

but in db I found different keys, oauth version, callbackUrl and grant_types as in screen attached DB screen Am I doing something wrong?

when i run the SOAP the response is

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:registerOAuthConsumerResponse xmlns:ns="http://org.apache.axis2/xsd" xmlns:ax2408="http://dto.oauth.identity.carbon.wso2.org/xsd" xmlns:ax2404="http://oauth.identity.carbon.wso2.org/xsd" xmlns:ax2405="http://base.identity.carbon.wso2.org/xsd"><ns:return>BE2JqA9lOZQKSkMvo4diNy2QHb0a</ns:return><ns:return>7xjxUrbWOztADfODEcvEbn8NeuEa</ns:return></ns:registerOAuthConsumerResponse></soapenv:Body></soapenv:Envelope>
Questioner
Jalisse
Viewed
0
Anuradha Karunarathna 2020-12-01 17:43:40

Taking the answer from the comments:

  1. The mentioned SOAP request is the 'registerOAuthApplicationData' request in https://localhost:9443/services/OAuthAdminService. The expected response should be similar to the sample response given in https://is.docs.wso2.com/en/latest/develop/service-provider-configurations-used-with-apis/#sample-request-and-response_1 (registerOAuthApplicationDataResponse) If a 'registerOAuthApplicationData' SOAP request is made "idn_oauth_consumer_apps" table entry should be populated with the given details (ie: provided client key, secret, callback etc)

  2. The mentioned SOAP response in the question is expected for the 'registerOAuthConsumer' request in https://localhost:9443/services/OAuthAdminService. It generates an OAuth consumer with randomly generated client key and secret and other default values. Such entry is reflected in your attached image.

That means you have executed an incorrect SOAP request.