Loading

Federated User Getting Unauthorized 401 While deploying Assets in Exchange

Publiseringsdato: Aug 1, 2025
Løsning

SYMPTOM

While executing the CI/CD to publish an artifact or consume an artifact to/from the Anypoint Exchange, the build getting failed with error caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for xxxx-dependancy

For Example :
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact status code: 401, reason phrase: Unauthorized (401)

 

CAUSE

  • settings.xml is not properly configured for the federated user.
  • using username / password to connect to Anypoint Exchange.
 

SOLUTION

If you are a Federated user and want to consume any federated assets from your organization, you need to properly configure your settings.xml otherwise you will get 401 -Unauthorised error while downloading any dependency from the Anypoint Exchange repository.
While consuming any assets using a federated user requires a Token authentication or Connected apps authentication defined in settings.xml.

To use token authentication: If you using a federated user which uses SSO to connect to the Anypoint follow the below approach:
  1. First, get a token using Get an API bearer token by using a SAML assertion , this is your access token.
  2. Open the settings.xml file at C:\Users\YOUR_USER_NAME\.m2\settings.xml on Windows, or at ~/.m2/settings.xml on macOS or Linux.
  3. Do change the value in <username> i.e. <username>~~~Token~~~</username>
  4. This value tells the Anypoint platform that you’re using a token.
  5. Set the value in <password> with the access token and save the settings.xml file.
sample settings.xml: 
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
          http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>Repository</id>
      <username>~~~Token~~~</username>
      <password>01234567-89ab-cdef-0123-456789abcdef</password>
    </server>
  </servers>
</settings>



To use connected application authentication:
  1. First, create Connected apps by referring to this doc connected-app-authentication
  2. configure the settings.xml with the authentication and define the username as ~~~Client~~~ and the password as clientID~?~clientSecret.
  3. Replace clientID with the <Client ID>
  4. Replace clientSecret with the <Client Secret>
  5. Include the connected application in the file settings.xml in your repository and save it.
sample stting.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    ...
    <server>
      <id>Repository</id>
      <username>~~~Client~~~</username>
      <password>clientID~?~clientSecret</password>
    </server>
  </servers>
</settings>


After configuring your settings.xml with either using Token authentication or Connected apps authentication, use the same settings.xml in CI/CD environment to publish, consume an asset and test your MUnit test cases.



 

Attachments

Furthermore reference visit : publish-and-consume-federated-assets

Knowledge-artikkelnummer

001122836

 
Laster
Salesforce Help | Article