• 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 5 years, 12 months ago by smkh.
Viewing 1 replies (of 1 total)
  • Thread Starter smkh

    (@smkh)

    Whenever i run Register function it returns console.error({error:’authToken failed’,message:res.error,url:RegisterURL})

    Which means error from API is :
    Invalid access, unverifiable ‘nonce’ value. Use the ‘get_nonce’ Core API method.

    • This reply was modified 5 years, 12 months ago by smkh.
Viewing 1 replies (of 1 total)
  • The topic ‘Invalid Nonce when registering user’ is closed to new replies.