Search code examples
ionic3linkedin-api

ng2-cordova-oauth LinkedIn integration is not working with IONIC 3


I am trying to integrate LinkedIN in my application and I am using IONIC3. I am following this https://medium.com/@vivek040997/how-to-implement-linkedin-oauth-2-0-login-in-ionic-4-dd892e792d6a to do integration. But this is working only with IONIC4 Application. As I am using IONIC 3 , it is not working.

import { HTTP } from "@ionic-native/http/ngx";
constructor(public http: HTTP) {

  }
  getAccessToken(authCode) {
    const body = {
        grant_type: "authorization_code",
        code: authCode,
        redirect_uri: "http://localhost/callback",
        client_id: "myclientid",
        client_secret: "myclientsecretid"
    };

    const headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    };

    return this.http.post(
        "https://www.linkedin.com/oauth/v2/accessToken",
        body,
        headers
    );
}

Below is my code to get access token.But I am getting below error. error TypeError: Object(...) is not a function at HTTP.post(vendor.js) Can anyone please help me how to do this .


Solution

  • change this

     import { HTTP } from "@ionic-native/http/ngx";
    

    to this

    import { HTTP } from "@ionic-native/http";
    

    Edit 2

    remove ionic native http

     npm uninstall  --save @ionic-native/http
    

    and install this version

    npm install @ionic-native/[email protected]