lazada-open-platform-sdk icon indicating copy to clipboard operation
lazada-open-platform-sdk copied to clipboard

generateAccessToken

Open hanstf opened this issue 6 years ago • 9 comments

Hi, do you know whether can I generateAccessToken with my seller user name and password ?

hanstf avatar Jun 14 '19 09:06 hanstf

No. generateAccessToken accepts code as a parameter. You can get code after authorizing your app through the Lazada Open Platform Authorization page.

Wizard-Rogue avatar Jun 14 '19 09:06 Wizard-Rogue

Thats sad, so they only have an implicit grant method ? Because I am a seller and wanted to do a server to server integration.

hanstf avatar Jun 14 '19 10:06 hanstf

Yes. But you can always just generate the URL yourself, open the URL in a browser, and then authorize your app. The code is returned as a URL query parameter on your callback. (i.e. https://callback.url?code=randomcode)

Wizard-Rogue avatar Jun 14 '19 11:06 Wizard-Rogue

Cannot generate access token with this package. My code is

const authCode = '0_118985_zUFFF5x0Wal7NNNRKPQFVjSZ2236' // replace valid authCode here const params = { code: authCode } const response = aLazadaAPI .generateAccessToken(params) .then(response => console.log(JSON.stringify(response, null, 4))) .catch(error => console.log(JSON.stringify(error, null, 4)))

getting this error "type": "ISV", "code": "IncompleteSignature", "message": "The request signature does not conform to lazada standards", "request_id": "0b86d3f015889470213992399"

Wizard-Rogue please help

sankar9659 avatar May 08 '20 14:05 sankar9659

@Wizard-Rogue please reply to my answer

sankar9659 avatar May 08 '20 14:05 sankar9659

Hi, are you looking at the examples/generateAccessToken.js ? Beware of the input params:

  1. appKey
  2. appSecret
  3. countryCode
  4. authCode

If any one of them had some issues, Lazada will not give you a token back.

const aLazadaAPI = new LazadaAPI('app_key', 'app_secret', 'country_code')

const authCode = 'auth_code' // replace valid authCode here
const params = {
  code: authCode,
}

Example errors:

IncompleteSignature Error

Something is wrong about the appSecret

{
    "type": "ISV",
    "code": "IncompleteSignature",
    "message": "The request signature does not conform to lazada standards",
    "request_id": "..."
}

InvalidCode Error

When authCode is expired.

{
    "code": "InvalidCode",
    "type": "ISP",
    "message": "Invalid authorization code",
    "request_id": "..."
}

InvalidAppKey Error

when appKey does not exist.

{
    "type": "ISV",
    "code": "InvalidAppKey",
    "message": "The specified App Key is invalid",
    "request_id": "..."
}

flow runtime error

Something is wrong about the countryCode

/[path]/lazada-open-platform-sdk/node_modules/flow-runtime/dist/flow-runtime.js:714
        throw error;
        ^

TypeError [RuntimeTypeError]: countryCode must be one of: "SINGAPORE" | "THAILAND" | "MALAYSIA" | "VIETNAM" | "PHILIPPINES" | "INDONESIA"

Expected: "SINGAPORE" | "THAILAND" | "MALAYSIA" | "VIETNAM" | "PHILIPPINES" | "INDONESIA"

Actual Value: "SINGAPOR"

Actual Type: string

    at new exports (/[path]/lazada-open-platform-sdk/lib/index.js:54:64)
    at Object.<anonymous> (/[path]/lazada-open-platform-sdk/examples/generateAccessToken.js:23:20)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  errors: [
    [
      [],
      'must be one of: "SINGAPORE" | "THAILAND" | "MALAYSIA" | "VIETNAM" | "PHILIPPINES" | "INDONESIA"',
      [UnionType]
    ]
  ]
}

conradlo avatar May 10 '20 13:05 conradlo

Hey @hanstf , did you figure out a way to generate code from code bypassing the oauth panel?

sarcastic-verma avatar May 04 '21 05:05 sarcastic-verma

Hi @hanstf did you find solution?

basic-code-info avatar Jul 12 '24 03:07 basic-code-info

how to get authcode. I need help getting order information

maithanhtoan1289 avatar Jul 22 '24 08:07 maithanhtoan1289