Code Monkey home page Code Monkey logo

Comments (4)

mychaelgo avatar mychaelgo commented on September 27, 2024

@ldw129 , please share the full code.. code above is for login request , not for transport estimate

from gojek.

mychaelgo avatar mychaelgo commented on September 27, 2024

or maybe the service type is not exists in those area

from gojek.

ldw129 avatar ldw129 commented on September 27, 2024

Hi @mychaelgo , thank you for your reply! For better clarity, below is the full edited code from:

  1. goid.js
const { TokenApi } = require('../../../sdk/goid-gojek-node/dist');

const tokenAPI = new TokenApi();

const defaultHeaders = {
    xAppid: 'com.gojek.app',
    xAppversion: '4.59.1',
    xDeviceos: 'Android,10',
    xPhonemake: 'Samsung',
    xPhonemodel: 'GT-S7500',
    xPlatform: 'Android',
    xPushtokentype: 'FCM',
    xUniqueid: '95f99ddd6a5d34a9',
    xUserType: 'customer'
};

const testLoginRequest = async () => {
    const loginResponse = await tokenAPI.loginRequest({
        ...defaultHeaders,
        loginRequestBody:{
            client_id: 'gojek:consumer:app',
            client_secret: 'pGwQ7oi8bKqqwvid09UrjqpkMEHklb',
            country_code: '+65',
            login_type: 'otp_whatsapp',
            magic_link_ref: '',
            phone_number: '81464126'
        }
    });

    console.log({ loginResponse: loginResponse.data  });
};

const testGenerateToken = async () => {
    const generateTokenResponse = await tokenAPI.generateToken({
        ...defaultHeaders,
        generateTokenRequest: {
            client_id: 'gojek:consumer:app',
            client_secret: 'pGwQ7oi8bKqqwvid09UrjqpkMEHklb',
            data: {
                otp: '2960',
                otp_token: 'd477d703-a5d3-43bb-92ce-7423929b0036'
            },
            grant_type: 'otp',
            scopes: []
        }
    });

    console.log({ generateTokenResponse: generateTokenResponse.data  });
};

// testLoginRequest();
testGenerateToken();
  1. get-transport-estimate.js
const { TransportApi, Configuration } = require('../../../sdk/api-gojek-node');

const configuration = new Configuration({
    accessToken: 'eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJhdWQiOlsiZ29qZWs6Y29uc3VtZXI6YXBwIl0sImRhdCI6eyJhY3RpdmUiOiJ0cnVlIiwiYmxhY2tsaXN0ZWQiOiJmYWxzZSIsImNvdW50cnlfY29kZSI6Iis2NSIsImNyZWF0ZWRfYXQiOiIyMDIwLTA3LTEyVDA0OjUxOjM3WiIsImVtYWlsIjoibGltZG9uZ3dhbjIwMTUyOEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJnb3BheV9hY2NvdW50X2lkIjoiMDEtYzNmOTZkNTk5Zjc2NDEzZThkZDUyZTcxMjA0ZGNiNmMtMjQiLCJuYW1lIjoiTGltIERvbmcgV2FuIiwibnVtYmVyIjoiODE0NjQxMjYiLCJwaG9uZSI6Iis2NTgxNDY0MTI2Iiwic2lnbmVkX3VwX2NvdW50cnkiOiJJRCIsIndhbGxldF9pZCI6IjIwMTk0MDI5MTQzMDk1ODEyNyJ9LCJleHAiOjE2ODIwNzIzNjQsImlhdCI6MTY3OTIzMzUyMywiaXNzIjoiZ29pZCIsImp0aSI6ImI2OWJhZWVhLTg5MGItNGY1OS05YzZiLWI2YTUwZWU3YWMwYiIsInNjb3BlcyI6W10sInNpZCI6IjJhMjNlZjdiLTIyMGMtNGJkMy04ZGU2LWQwNzM2MmM3YTVjMyIsInN1YiI6ImQ0NTkyZDg4LTBkMDctNDhkYS1hNWUzLTc2NmEyZGNhNWYwZiIsInVpZCI6IjY4NTA1NjQ3NiIsInV0eXBlIjoiY3VzdG9tZXIifQ.OwQZeIjD_l11YuSEQ6Sdm6aqitdl6ny8tvCmilHacuhRsCMpWRvVq-1BWaWg2lyfT0WBtZfe43GuFQcyh-7V1Qmjr16DRhn6bMvqaRXY6gAPYe24C_vXoCIzT9Ieb8DiJkSv9sdxEE8pEHRPs9Mpk3uT6tK5UvetTxrvrFKseq0'
});

// const configuration = new Configuration({
//     accessToken: process.env.GOJEK_ACCESS_TOKEN
// });

const transportAPI = new TransportApi(configuration);

const defaultHeaders = {
    xAppid: 'com.gojek.app',
    xAppversion: '4.59.1',
    xDeviceos: 'Android,10',
    xPhonemake: 'Samsung',
    xPhonemodel: 'GT-S7500',
    xPlatform: 'Android',
    xPushtokentype: 'FCM',
    xUniqueid: '95f99ddd6a5d34a9',
    xUserType: 'customer',
    xSessionId: 'd31cc210-a067-4d0d-a52f-199880ea8907',
    gojekCountryCode: 'ID'
};

const getTransportEstimate = async () => {
    
    const getTransportEstimateResponse = await transportAPI.getTransportEstimate({
        ...defaultHeaders,
        sendPrioritisedOrder: true,
        userSelectedServiceType: 1,
        waypoints: '1.3376415,103.6947157|1.3336745,103.6758544'
    });

    console.log(JSON.stringify(getTransportEstimateResponse.data));
};

getTransportEstimate();

Just to clarify, I first ran goid.js to get the OTP from Gojek and generate the access token, then I ran get-transport-estimate.js using the access token generated. This was where the error, as mentioned in my first comment above, surfaced.

Thank you!

from gojek.

haiqaldani avatar haiqaldani commented on September 27, 2024

i wanna ask i get 400 error, im using waypoint in singapore

from gojek.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.