Skip to content

Error 1149 Please provide 'os' #5

@josros

Description

@josros

I am trying to authenticate using this method: https://docs.pcloud.com/methods/intro/authentication.html
But I always get the following response: { result: 1149, error: "Please provide 'os'." }
The docs do not say anything about an 'os' parameter.

Here is the testscript I wrote:

async function getPCloudToken() {
    try {
      // Step 1: Get the digest from pCloud
      const digestResponse = await axios.get('https://eapi.pcloud.com/getdigest');
      const { digest, result } = digestResponse.data;
  
      if (result !== 0) {
        throw new Error('Failed to get digest');
      }
      

      // Step 2: Prepare the passworddigest (sha1(password + sha1(lowercase(username)) + digest))
      const lowercaseUsername = username.toLowerCase();
      const usernameHash = crypto.createHash('sha1').update(lowercaseUsername).digest('hex');
      const passworddigest = crypto.createHash('sha1').update(password + usernameHash + digest).digest('hex');

  
      // Step 3: Request the auth token using the hashed password
      const loginResponse = await axios.get('https://eapi.pcloud.com/login', {
        params: {
          getauth: 1,
          digest,
          username,
          passworddigest,
          deviceid: 'TestApp-Device-ID',
          os: 'linux', // test to overcome os requirement
        },
        headers: {
          'User-Agent': 'TestApp/1.0 (Linux; x86_64)',  // test to overcome os requirement
        },
      });
  
      const { auth, result: loginResult, error } = loginResponse.data;
  
      if (loginResult === 0) {
        console.log('Auth token:', auth);
        return auth;
      } else {
        console.error('Login response:', loginResponse.data);
        throw new Error(`Login failed: ${error}`);
      }
    } catch (error) {
      console.error('Error fetching pCloud token:', error);
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions