Sample code for 30+ languages & platforms
DataFlex

Azure Fetch OpenID Connect metadata document

See more OIDC Examples

Downloads the OpenID Connect self-discovery document for an Azure OIDC enabled app.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vResp
    Handle hoResp
    Handle hoJson
    String sStrVal
    String sToken_endpoint
    String sJwks_uri
    String sIssuer
    Boolean iRequest_uri_parameter_supported
    String sUserinfo_endpoint
    String sAuthorization_endpoint
    String sDevice_authorization_endpoint
    Boolean iHttp_logout_supported
    Boolean iFrontchannel_logout_supported
    String sEnd_session_endpoint
    String sKerberos_endpoint
    String sTenant_region_scope
    String sCloud_instance_name
    String sCloud_graph_host_name
    String sMsgraph_host
    String sRbac_url
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComAccept Of hoHttp To "application/json"

    // See the Microsoft Azure OIDC documentation at https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc
    // The "tenant" can take one of four values described in the documentation at the link above.

    Get ComSetUrlVar Of hoHttp "tenant" "6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd" To iSuccess
    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoResp to vResp
    Get ComHttpNoBody Of hoHttp "GET" "https://login.microsoftonline.com/{$tenant}/v2.0/.well-known/openid-configuration" vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln "Response Status Code: " iTemp1

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoad Of hoJson sTemp1 To iSuccess
    Set ComEmitCompact Of hoJson To False
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 <> 200) Begin
        Showln "Failed."
        Procedure_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

    // {
    //   "token_endpoint": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/oauth2/v2.0/token",
    //   "token_endpoint_auth_methods_supported": [
    //     "client_secret_post",
    //     "private_key_jwt",
    //     "client_secret_basic"
    //   ],
    //   "jwks_uri": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/discovery/v2.0/keys",
    //   "response_modes_supported": [
    //     "query",
    //     "fragment",
    //     "form_post"
    //   ],
    //   "subject_types_supported": [
    //     "pairwise"
    //   ],
    //   "id_token_signing_alg_values_supported": [
    //     "RS256"
    //   ],
    //   "response_types_supported": [
    //     "code",
    //     "id_token",
    //     "code id_token",
    //     "id_token token"
    //   ],
    //   "scopes_supported": [
    //     "openid",
    //     "profile",
    //     "email",
    //     "offline_access"
    //   ],
    //   "issuer": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/v2.0",
    //   "request_uri_parameter_supported": false,
    //   "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo",
    //   "authorization_endpoint": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/oauth2/v2.0/authorize",
    //   "device_authorization_endpoint": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/oauth2/v2.0/devicecode",
    //   "http_logout_supported": true,
    //   "frontchannel_logout_supported": true,
    //   "end_session_endpoint": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/oauth2/v2.0/logout",
    //   "claims_supported": [
    //     "sub",
    //     "iss",
    //     "cloud_instance_name",
    //     "cloud_instance_host_name",
    //     "cloud_graph_host_name",
    //     "msgraph_host",
    //     "aud",
    //     "exp",
    //     "iat",
    //     "auth_time",
    //     "acr",
    //     "nonce",
    //     "preferred_username",
    //     "name",
    //     "tid",
    //     "ver",
    //     "at_hash",
    //     "c_hash",
    //     "email"
    //   ],
    //   "kerberos_endpoint": "https://login.microsoftonline.com/6d8ddd66-68d1-44b0-af5c-e31b4b7ee5cd/kerberos",
    //   "tenant_region_scope": "NA",
    //   "cloud_instance_name": "microsoftonline.com",
    //   "cloud_graph_host_name": "graph.windows.net",
    //   "msgraph_host": "graph.microsoft.com",
    //   "rbac_url": "https://pas.windows.net"
    // }

    Get ComStringOf Of hoJson "token_endpoint" To sToken_endpoint
    Get ComStringOf Of hoJson "jwks_uri" To sJwks_uri
    Get ComStringOf Of hoJson "issuer" To sIssuer
    Get ComBoolOf Of hoJson "request_uri_parameter_supported" To iRequest_uri_parameter_supported
    Get ComStringOf Of hoJson "userinfo_endpoint" To sUserinfo_endpoint
    Get ComStringOf Of hoJson "authorization_endpoint" To sAuthorization_endpoint
    Get ComStringOf Of hoJson "device_authorization_endpoint" To sDevice_authorization_endpoint
    Get ComBoolOf Of hoJson "http_logout_supported" To iHttp_logout_supported
    Get ComBoolOf Of hoJson "frontchannel_logout_supported" To iFrontchannel_logout_supported
    Get ComStringOf Of hoJson "end_session_endpoint" To sEnd_session_endpoint
    Get ComStringOf Of hoJson "kerberos_endpoint" To sKerberos_endpoint
    Get ComStringOf Of hoJson "tenant_region_scope" To sTenant_region_scope
    Get ComStringOf Of hoJson "cloud_instance_name" To sCloud_instance_name
    Get ComStringOf Of hoJson "cloud_graph_host_name" To sCloud_graph_host_name
    Get ComStringOf Of hoJson "msgraph_host" To sMsgraph_host
    Get ComStringOf Of hoJson "rbac_url" To sRbac_url
    Move 0 To i
    Get ComSizeOfArray Of hoJson "token_endpoint_auth_methods_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "token_endpoint_auth_methods_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "response_modes_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "response_modes_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "subject_types_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "subject_types_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "id_token_signing_alg_values_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "id_token_signing_alg_values_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "response_types_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "response_types_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "scopes_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "scopes_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "claims_supported" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "claims_supported[i]" To sStrVal
        Move (i + 1) To i
    Loop



End_Procedure