I am trying to get oauth2 working. I went through...
# suitescript
a
I am trying to get oauth2 working. I went through the steps and now I have what I think is a valid
access_token
I am trying to use it to make a request to a restlet. I am adding the header:
Authorization: Bearer ${auth_token}
But I keep getting The error
LOGIN_REQD
b
sounds a little strange, usually you get a 401 status code
and a response body which says json that includes
INVALID_LOGIN_ATTEMPT
a
I do get a 401. This is the message of the 401
Copy code
export async function runnetsuitequery(command: string, args: (number | string)[], token: string){
    const path =  root + "/app/site/hosting/restlet.nl?cript=1884&deploy=1"
    const body = {
        command, args
    }

    const headers = {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
    }

    const response = await fetch(path, {
        method: 'POST',
        body: JSON.stringify(body),
        headers: headers
    })

    return response.json()

}
b
wrong url
?
a
what do you mean?
b
are you doing something like using the internal url instead of the external url?
this is the url it is posting to.
I'm an idiot. I hardcoded the sandbox account and was authenticating the oauth2 with my production account