Skip to content

Commit

Permalink
more fixes to captcha snippets
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Earnshaw <[email protected]>
  • Loading branch information
nearnshaw authored Dec 7, 2023
1 parent 1c74416 commit efa80be
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions content/creator/rewards/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ import { signedFetch } from '@decentraland/SignedFetch'
import { getUserData } from '@decentraland/Identity'

const user = await getUserData({})
const request = await signedFetch({
if(!user || !user.data || user.data.publicKey) return
const response = await signedFetch({
url:'https://rewards.decentraland.org/api/rewards',
init:{
method: 'POST',
Expand All @@ -126,13 +127,16 @@ const request = await signedFetch({
},
body: JSON.stringify({
campaign_key: '[DISPENSER_KEY]',
beneficiary: user.publicKey,
beneficiary: user.data.publicKey,
}),
}
})

const response = await request.json()
console.log(response)
if (!response || !response.body) {
throw new Error('Invalid response')
}
let json = await JSON.parse(response.body)
console.log(json)

// Response:
//
Expand Down Expand Up @@ -204,7 +208,8 @@ import { signedFetch } from '@decentraland/SignedFetch'
import { getUserData } from '@decentraland/Identity'

const user = await getUserData({})
const request = await signedFetch({
if(!user || !user.data || !user.data.publicKey) return
const response = await signedFetch({
url: 'https://rewards.decentraland.org/api/rewards',
init: {
method: 'POST',
Expand All @@ -213,15 +218,18 @@ const request = await signedFetch({
},
body: JSON.stringify({
campaign_key: '[DISPENSER_KEY]',
beneficiary: user.publicKey,
beneficiary: user.data.publicKey,
captcha_id: '[CAPTCHA_ID]', // "9e6b2d07-b47b-4204-ae87-9c4dea48f9b7"
captcha_value: '[CAPTCHA_VALUE]', // "dbdcbf" or "DBDCBF"
}),
}
})

const response = await request.json()
console.log(response)
if (!response || !response.body) {
throw new Error('Invalid response')
}
let json = await JSON.parse(response.body)
console.log(json)

// Response:
//
Expand Down Expand Up @@ -277,7 +285,8 @@ import { getUserData } from '@decentraland/Identity'

const user = await getUserData({})
const realm = await getRealm({})
const request = await signedFetch({
if(!user || !user.data || !user.data.publicKey || !realm || !realm.baseUrl) return
const response = await signedFetch({
url: 'https://rewards.decentraland.org/api/rewards',
init: {
method: 'POST',
Expand All @@ -286,14 +295,17 @@ const request = await signedFetch({
},
body: JSON.stringify({
campaign_key: '[DISPENSER_KEY]',
beneficiary: user.publicKey,
catalyst: realm.domain,
beneficiary: user.data.publicKey,
catalyst: realm.baseUrl,
}),
}
})

const response = await request.json()
console.log(response)
if (!response || !response.body) {
throw new Error('Invalid response')
}
let json = await JSON.parse(response.body)
console.log(json)

// Response:
//
Expand Down

0 comments on commit efa80be

Please sign in to comment.