Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 454727

Invalid Nonce when registering user

$
0
0

Replies: 1

Dear Admin,

I am a student and was searching exactly something like, this i just started with this plugin, it is awesome and a complete solution!.

But now the problem i am facing is that it works fine while using it in the browser, but not when i use it in the ReactNative App, the error i am getting is invalid nonce, The nonce is generated succesully but when i try to register the user with nonce i am getting error that nonce is invalid

Error: “Invalid access, unverifiable ‘nonce’ value. Use the ‘get_nonce’ Core API method

Here’s My Code:

GENERATING NONCE:-

let GetNonce=(url)=>{

return new Promise((resolve,reject)=>{
fetch(url+?json=core.get_nonce&controller=user&method=register).then(response => response.json()).then((r)=>{

if(r.status== “ok”){
resolve(r)

}else{
reject({error:r.status,message:”Couldn’t generate auth token, Make sure you have allowed CORS header on your website”})

}
})
.catch(e=>{

return reject(e)
})
})

}

NOW REGISTERING :=

let Register=(OBJ)=>{

const {email,pass,username,url}=OBJ

GetNonce(url).then(r=>{

let RegisterURL = url+/api/user/register/?username=${username}&email=${email}&nonce=${r.nonce}&display_name=${username}&notify=both&user_pass=${pass}
fetch(RegisterURL).then(response => response.json()) //Convert to json
.then(res=>{

if(res.error = “Invalid access, unverifiable ‘nonce’ value. Use the ‘get_nonce’ Core API method. “){
return console.error({error:’authToken failed’,message:res.error,url:RegisterURL})
}
if(res.status==”ok”){

//User has been registered!.. Login Now!..
console.log(res)
}
else{
return console.error({error:res.status,message:”An error accured, Make sure to allow CORS origin from your wordpress site!.”,response:res})
}

})
.catch(e=> reject(e) )

}).catch(e=> reject(e))

}

  • This topic was modified 14 minutes ago by smkh.

Viewing all articles
Browse latest Browse all 454727

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>