mychaelgo / gojek

Un-official Gojek & GoPay API Wrapper
MIT License
59 stars 15 forks source link

GoID Generate Access Token #21

Closed woonyee28 closed 1 year ago

woonyee28 commented 1 year ago

Hi! Thanks for updating us regarding the API for goid.gojekapi.com. However, I seems to encounter a 'missing field' error when I was requesting OTP. Below is my code:

curl -X POST \
  https://goid.gojekapi.com/goid/login/request \
  -H 'Content-Type: application/json' \
  -H 'x-user-type: customer' \
  -d '{
    "client_id": "gojek:consumer:app",
    "client_secret": "pGwQ7oi8bKqqwvid09UrjqpkMEHklb",
    "country_code": "+65",
    "login_type": "otp_whatsapp",
    "magic_link_ref": "",
    "phone_number": "MY_PHONE_NUMBER"
  }'

And this is the error: ":[{"code":"goid:error:missing_field","message":"One of the required fields is missing","message_title":"Missing information"}]}

When I am requesting the access token using example OTP, this is my code:

curl -X POST \
  https://goid.gojekapi.com/goid/token \
  -H 'Content-Type: application/json' \
  -H 'x-appversion: 4.59.1' \
  -H 'x-appid: com.gojek.app' \
  -H 'x-deviceos: Android,10' \
  -H 'x-user-type: customer' \
  -H 'x-phonemake: Samsung' \
  -H 'x-phonemodel: GT-S7500' \
  -d '{
    "client_id": "gojek:consumer:app",
    "client_secret": "pGwQ7oi8bKqqwvid09UrjqpkMEHklb",
    "grant_type": "otp",
    "data": {
        "otp": "123456",
        "otp_token": "2dee3ede-f329-4d27-802d-754205e38a22"
    },
    "scopes": []
}
'

This doesnt work and the error is the same: {"data":null,"success":false,"errors":[{"code":"goid:error:missing_field","message":"One of the required fields is missing","message_title":"Missing information"}]} I suppose the error is because I am using example otp and otp_token?

Besides, may I know how can I generate / find my client_secret? Cuz I have been using the default one and I think it might be a problem?

Thanks in advance :D

mychaelgo commented 1 year ago

@woonyee28 you are missing the headers, please take a look at the example https://github.com/mychaelgo/gojek/tree/master/examples/node/goid#login-request

woonyee28 commented 1 year ago

Perfect! It works! Thank you very much Mychael for the pointer, appreciate it a lot.

To those who are viewing this issue and had a problem running the goid.js. I downloaded the repo locally, direct to https://github.com/mychaelgo/gojek/tree/master/sdk/goid-gojek-node, run npm install, then go back to https://github.com/mychaelgo/gojek/blob/master/examples/node/goid/goid.js to run the file.