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

[Not issue] Help me please with auth #4

Open
rudnik275 opened this issue Oct 25, 2024 · 1 comment
Open

[Not issue] Help me please with auth #4

rudnik275 opened this issue Oct 25, 2024 · 1 comment
Labels
question Further information is requested

Comments

@rudnik275
Copy link

Hello, sumad200, I dont know how to contact with you so I write here.
I try to do local project for personal usage to check what's new in my valorant shop and night market from my telegram bot.
But I have error on auth, I use bun (or nodejs) for my app.

Here my code

  // Make the first request to obtain session cookies
  const step1Response = await fetch('https://auth.riotgames.com/api/v1/authorization', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      client_id: 'riot-client',
      code_challenge: '',
      code_challenge_method: '',
      acr_values: '',
      claims: '',
      nonce: '69420',
      redirect_uri: 'http://localhost/redirect',
      response_type: 'token id_token',
      scope: 'openid link ban lol_region',
    }),
  })

// Check the response status and cookies
  if (!step1Response.ok) {
    console.error('Step 1 failed:', await step1Response.text())
    return
  }

// Extract cookies from the response
  const setCookieHeader = step1Response.headers.get('set-cookie')
  if (!setCookieHeader) {
    console.error('No cookies received from Step 1')
    return
  }

// Prepare cookies for the second request
  const cookies = setCookieHeader.split(', ').map(cookie => cookie.split(';')[0]).join('; ')

// Make the second request using the cookies
  const step2Response = await fetch('https://auth.riotgames.com/api/v1/authorization', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Cookie': cookies,  // Pass cookies from Step 1
    },
    body: JSON.stringify({
      remember: true,
      type: 'auth',
      username: process.env.RIOT_USERNAME,
      password: process.env.RIOT_PASSWORD,
    }),
  })

  console.log(
    process.env.RIOT_USERNAME,
    process.env.RIOT_PASSWORD,
  )
  const step2Data = await step2Response.json()
  if (!step2Response.ok) {
    console.error('Step 2 failed:', step2Data)
  } else {
    console.log('Step 2 successful:', step2Data)
  }

}

test()

but server respond me 200, but with next response:

Step 2 successful: {
  type: "auth",
  error: "auth_failure",
  country: "ukr",
}

What I doing wrong?

@rudnik275 rudnik275 changed the title Help me please with auth [Not issue] Help me please with auth Oct 25, 2024
@sumad200
Copy link
Owner

sumad200 commented Oct 28, 2024

Hey @rudnik275, The auth endpoint request body has changed .I've switched to using a webview for authentication. So, I no longer update any auth endpoint related code in my app. You should check out these resources for the latest info.

Techrism's val api docs
Valorant App developers discord - For support and info on breaking changes as they happen

I also suggest you try getting the auth flow right first using postman/insomnia before coding, Also you can take a look at this discord bot repo (in python) as it matches your use case more closely.

Edit: Found a js discord bot https://github.com/giorgi-o/SkinPeek/

@sumad200 sumad200 added the question Further information is requested label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants