Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 1149 Please provide 'os' #5

Open
josros opened this issue Oct 23, 2024 · 1 comment
Open

Error 1149 Please provide 'os' #5

josros opened this issue Oct 23, 2024 · 1 comment

Comments

@josros
Copy link

josros commented Oct 23, 2024

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);
    }
  }
@theroot79
Copy link

Hello,
please, use oauth to get Auth token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants