Sample code for 30+ languages & platforms
SQL Server

OneLogin OIDC - Get Discovery Document (OpenID Connect)

See more OneLogin OIDC Examples

Downloads the OpenID Connect self-discovery document for a OneLogin OIDC enabled app.

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  This example requires the Chilkat API to have been previously unlocked.
    --  See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @http, 'Accept', 'application/json'

    DECLARE @resp int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT

    EXEC sp_OAMethod @http, 'HttpNoBody', @success OUT, 'GET', 'https://<account>.onelogin.com/oidc/.well-known/openid-configuration', @resp
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @resp
        RETURN
      END


    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT 'Response Status Code: ' + @iTmp0

    DECLARE @jsonResponse int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonResponse OUT

    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    EXEC sp_OAMethod @jsonResponse, 'Load', @success OUT, @sTmp0
    EXEC sp_OASetProperty @jsonResponse, 'EmitCompact', 0
    EXEC sp_OAMethod @jsonResponse, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    IF @iTmp0 <> 200
      BEGIN

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @resp
        EXEC @hr = sp_OADestroy @jsonResponse
        RETURN
      END

    --  Sample output...
    --  (See the parsing code below..)
    --  
    --  Use the this online tool to generate parsing code from sample JSON: 
    --  Generate Parsing Code from JSON

    --  {
    --    "acr_values_supported": [
    --      "onelogin:nist:level:1:re-auth"
    --    ],
    --    "authorization_endpoint": "https://chilkat-dev.onelogin.com/oidc/auth",
    --    "claims_parameter_supported": true,
    --    "claims_supported": [
    --      "acr",
    --      "auth_time",
    --      "company",
    --      "custom_fields",
    --      "department",
    --      "email",
    --      "family_name",
    --      "given_name",
    --      "groups",
    --      "iss",
    --      "locale_code",
    --      "name",
    --      "params",
    --      "phone_number",
    --      "preferred_username",
    --      "sid",
    --      "sub",
    --      "title",
    --      "updated_at"
    --    ],
    --    "grant_types_supported": [
    --      "authorization_code",
    --      "implicit",
    --      "refresh_token",
    --      "client_credentials",
    --      "password"
    --    ],
    --    "id_token_signing_alg_values_supported": [
    --      "RS256"
    --    ],
    --    "issuer": "https://openid-connect.onelogin.com/oidc",
    --    "jwks_uri": "https://chilkat-dev.onelogin.com/oidc/certs",
    --    "request_parameter_supported": false,
    --    "request_uri_parameter_supported": false,
    --    "response_modes_supported": [
    --      "form_post",
    --      "fragment",
    --      "query"
    --    ],
    --    "response_types_supported": [
    --      "code",
    --      "id_token token",
    --      "id_token"
    --    ],
    --    "scopes_supported": [
    --      "openid",
    --      "name",
    --      "profile",
    --      "groups",
    --      "email",
    --      "params",
    --      "phone"
    --    ],
    --    "subject_types_supported": [
    --      "public"
    --    ],
    --    "token_endpoint": "https://chilkat-dev.onelogin.com/oidc/token",
    --    "token_endpoint_auth_methods_supported": [
    --      "client_secret_basic",
    --      "client_secret_post",
    --      "none"
    --    ],
    --    "userinfo_endpoint": "https://chilkat-dev.onelogin.com/oidc/me",
    --    "userinfo_signing_alg_values_supported": [
    --    ],
    --    "code_challenge_methods_supported": [
    --      "S256"
    --    ],
    --    "introspection_endpoint": "https://chilkat-dev.onelogin.com/oidc/token/introspection",
    --    "introspection_endpoint_auth_methods_supported": [
    --      "client_secret_basic",
    --      "client_secret_post",
    --      "none"
    --    ],
    --    "revocation_endpoint": "https://chilkat-dev.onelogin.com/oidc/token/revocation",
    --    "revocation_endpoint_auth_methods_supported": [
    --      "client_secret_basic",
    --      "client_secret_post",
    --      "none"
    --    ],
    --    "claim_types_supported": [
    --      "normal"
    --    ]
    --  }
    --  

    DECLARE @authorization_endpoint nvarchar(4000)

    DECLARE @claims_parameter_supported int

    DECLARE @issuer nvarchar(4000)

    DECLARE @jwks_uri nvarchar(4000)

    DECLARE @request_parameter_supported int

    DECLARE @request_uri_parameter_supported int

    DECLARE @token_endpoint nvarchar(4000)

    DECLARE @userinfo_endpoint nvarchar(4000)

    DECLARE @introspection_endpoint nvarchar(4000)

    DECLARE @revocation_endpoint nvarchar(4000)

    DECLARE @i int

    DECLARE @count_i int

    DECLARE @strVal nvarchar(4000)

    EXEC sp_OAMethod @jsonResponse, 'StringOf', @authorization_endpoint OUT, 'authorization_endpoint'
    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @claims_parameter_supported OUT, 'claims_parameter_supported'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @issuer OUT, 'issuer'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @jwks_uri OUT, 'jwks_uri'
    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @request_parameter_supported OUT, 'request_parameter_supported'
    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @request_uri_parameter_supported OUT, 'request_uri_parameter_supported'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @token_endpoint OUT, 'token_endpoint'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @userinfo_endpoint OUT, 'userinfo_endpoint'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @introspection_endpoint OUT, 'introspection_endpoint'
    EXEC sp_OAMethod @jsonResponse, 'StringOf', @revocation_endpoint OUT, 'revocation_endpoint'
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'acr_values_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'acr_values_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'claims_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'claims_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'grant_types_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'grant_types_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'id_token_signing_alg_values_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'id_token_signing_alg_values_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'response_modes_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'response_modes_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'response_types_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'response_types_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'scopes_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'scopes_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'subject_types_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'subject_types_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'token_endpoint_auth_methods_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'token_endpoint_auth_methods_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'userinfo_signing_alg_values_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'code_challenge_methods_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'code_challenge_methods_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'introspection_endpoint_auth_methods_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'introspection_endpoint_auth_methods_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'revocation_endpoint_auth_methods_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'revocation_endpoint_auth_methods_supported[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'claim_types_supported'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @strVal OUT, 'claim_types_supported[i]'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @resp
    EXEC @hr = sp_OADestroy @jsonResponse


END
GO