Functions

The following functions are available globally.

  • Auth0 Authentication API client to authenticate your user using Database, Social, Enterprise or Passwordless connections.

    Auth0.authentication(clientId: clientId, domain: "samples.auth0.com")
    

    Declaration

    Swift

    public func authentication(clientId: String, domain: String, session: URLSession = .shared) -> Authentication

    Parameters

    clientId

    Client ID of your Auth0 application.

    domain

    Domain of your Auth0 account, e.g. ‘samples.auth0.com’.

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    Return Value

    Auth0 Authentication API client.

  • Auth0 Authentication API client to authenticate your user using Database, Social, Enterprise or Passwordless connections.

    Auth0.authentication()
    

    The Auth0 Client ID & Domain are loaded from the Auth0.plist file in your main bundle. It should have the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>ClientId</key>
      <string>YOUR_AUTH0_CLIENT_ID</string>
      <key>Domain</key>
      <string>YOUR_AUTH0_DOMAIN</string>
    </dict>
    </plist>
    

    Important

    Calling this method without a valid Auth0.plist file will crash your application.

    Declaration

    Swift

    public func authentication(session: URLSession = .shared, bundle: Bundle = .main) -> Authentication

    Parameters

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    bundle

    Bundle used to locate the Auth0.plist file. Defaults to Bundle.main.

    Return Value

    Auth0 Authentication API client.

  • Auth0 Management API v2 client to perform operations with the Users endpoints.

    Auth0.users(token: credentials.accessToken)
    

    Currently you can only perform the following operations:

    • Get a user by ID
    • Update an user, e.g. by adding user_metadata
    • Link users
    • Unlink users

    The Auth0 Domain is loaded from the Auth0.plist file in your main bundle. It should have the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>ClientId</key>
      <string>YOUR_AUTH0_CLIENT_ID</string>
      <key>Domain</key>
      <string>YOUR_AUTH0_DOMAIN</string>
    </dict>
    </plist>
    

    Important

    Calling this method without a valid Auth0.plist file will crash your application.

    Declaration

    Swift

    public func users(token: String, session: URLSession = .shared, bundle: Bundle = .main) -> Users

    Parameters

    token

    Management API token with the correct allowed scopes to perform the desired action.

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    bundle

    Bundle used to locate the Auth0.plist file. Defaults to Bundle.main.

    Return Value

    Auth0 Management API v2 client.

  • Auth0 Management API v2 client to perform operations with the Users endpoints.

    Auth0.users(token: credentials.accessToken, domain: "samples.auth0.com")
    

    Currently you can only perform the following operations:

    • Get a user by ID
    • Update an user, e.g. by adding user_metadata
    • Link users
    • Unlink users

    Declaration

    Swift

    public func users(token: String, domain: String, session: URLSession = .shared) -> Users

    Parameters

    token

    Management API token with the correct allowed scopes to perform the desired action.

    domain

    Domain of your Auth0 account, e.g. ‘samples.auth0.com’.

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    Return Value

    Auth0 Management API v2 client.

  • Auth0 client for performing web-based authentication with Universal Login.

    Auth0.webAuth()
    

    The Auth0 Domain is loaded from the Auth0.plist file in your main bundle. It should have the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>ClientId</key>
       <string>YOUR_AUTH0_CLIENT_ID</string>
       <key>Domain</key>
       <string>YOUR_AUTH0_DOMAIN</string>
    </dict>
    </plist>
    

    Important

    Calling this method without a valid Auth0.plist file will crash your application.

    Declaration

    Swift

    public func webAuth(session: URLSession = .shared, bundle: Bundle = Bundle.main) -> WebAuth

    Parameters

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    bundle

    Bundle used to locate the Auth0.plist file. Defaults to Bundle.main.

    Return Value

    Auth0 Web Auth client.

  • Auth0 client for performing web-based authentication with Universal Login.

    Auth0.webAuth(clientId: clientId, domain: "samples.auth0.com")
    

    Declaration

    Swift

    public func webAuth(clientId: String, domain: String, session: URLSession = .shared) -> WebAuth

    Parameters

    clientId

    Client ID of your Auth0 application.

    domain

    Domain of your Auth0 account, e.g. ‘samples.auth0.com’.

    session

    URLSession instance used for networking. Defaults to URLSession.shared.

    Return Value

    Auth0 Web Auth client.

  • Auth0 client for performing web-based authentication with Universal Login.

    Auth0.webAuth()
    

    The Auth0 Domain is loaded from the Auth0.plist file in your main bundle. It should have the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>ClientId</key>
       <string>YOUR_AUTH0_CLIENT_ID</string>
       <key>Domain</key>
       <string>YOUR_AUTH0_DOMAIN</string>
    </dict>
    </plist>
    

    Important

    Calling this method without a valid Auth0.plist file will crash your application.
  • Auth0 client for performing web-based authentication with Universal Login.

    Auth0.webAuth(clientId: clientId, domain: "samples.auth0.com")