Skip to content

[Not issue] Help me please with auth #4

Description

@rudnik275

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?

Activity

  1. changed the title [-]Help me please with auth[/-] [+][Not issue] Help me please with auth[/+] on Oct 25, 2024
  2. sumad200 commented on Oct 28, 2024

    @sumad200
    Owner

    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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions