Error `OAuth signature not defined` with Ionic-Angular app











up vote
0
down vote

favorite












I have an ionic-angular app nkvshopapp with wordpress as backend. Wordpress is locally hosted with oauth1.0 plugin and oauth keys defined.



Until yesterday morning, nkvshopapp was working fine and it displayed all of posts and categories from my wordpress website. It stopped working all of a sudden and now it displays error OAuth signature not defined. OAuth signature not defined error I double-checked OAuth keys and they were same as before (i.e. not regenerated anew). App`s index.html and config.ts both are same as before. My app is designed to load an additional Javascript (nkvshopapp.js) so I checked OAuth function within nkvshopapp.js too (in case anyone hacked my PC and made changes to it...getting paranoid, I know :)



Finally, I double-checked in Postman if Oauth keys are being authenticated; and Postman does not display any error or warning. Call validation in Postman



Am I missing anything? Any suggestions or pointers would be very helpful.
Pls help.



Here are extracts of index.html, config.ts and nkvshopapp.js.



./index.html:



<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>NKVShop</title>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">

<link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#4e8ef7">

<!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<!-- cordova.js required for cordova apps -->
<script src="cordova.js"></script>
<script src="nkvshopapp.js"></script>

</script>-->


./app/www/nkvshopapp.js:



function OAuthSignature() {
}

OAuthSignature.prototype.generate = function (httpMethod, url, parameters, consumerSecret, tokenSecret, options) {
var signatureBaseString = new SignatureBaseString(httpMethod, url, parameters).generate();
var encodeSignature = true;
if (options) {
encodeSignature = options.encodeSignature;
}
return new HmacSha1Signature(signatureBaseString, consumerSecret, tokenSecret).generate(encodeSignature);
//return new signatureBaseString;
};

// Specification: http://oauth.net/core/1.0/#anchor14
// url: if the scheme is missing, http will be added automatically
function SignatureBaseString(httpMethod, url, parameters) {
//parameters = new ParametersLoader(parameters).get();
this._httpMethod = new HttpMethodElement(httpMethod).get();
this._url = new UrlElement(url).get();
this._parameters = parameters;
//this._parameters = new ParametersElement(parameters).get();
this._rfc3986 = new Rfc3986();
}

SignatureBaseString.prototype = {
generate : function () {
// HTTP_METHOD & url & parameters
return this._rfc3986.encode(this._httpMethod) + '&'
+ this._rfc3986.encode(this._url) + '&'
+ this._rfc3986.encode(this._parameters);
}
};


./src/providers/service/config.ts:



import { Injectable } from '@angular/core';
import { URLSearchParams } from '@angular/http';
import { Headers } from '@angular/http';
declare var oauthSignature: any;
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
@Injectable()
export class Config {
url: any = 'http://127.0.1.1:8080/wordpress';
consumerKey: any = 'Hl8XcAPgCqt6';
consumerSecret: any = '3xGMKgiXBP7HoI2i9dkf3HByepZRSmSjYGQNszvXwzfOO0YW';
oneSignalAppId: any = '';
googleProjectId: any = '';
language: any = 'english';
appDir: any = 'ltr';

appRateIosAppId: any = '12345678';
appRateAndroidLink: any = '';
appRateWindowsId: any = '12345678';
shareAppMessage: any = 'download it';
shareAppSubject: any = 'Hi';
shareAppURL: any = '';
shareAppChooserTitle: any = 'select app';
supportEmail: any = 'nkvshopapp@gmail.com';

oauth: any;
signedUrl: any;
randomString: any;
oauth_nonce: any;
oauth_signature_method: any;
encodedSignature: any;
searchParams: any;
customer_id: any;
params: any;
options: any = {};
constructor() {
this.options.withCredentials = true;
this.options.headers = headers;
this.oauth = oauthSignature;
this.oauth_signature_method = 'HMAC-SHA1';
this.searchParams = new URLSearchParams();
this.params = {};
this.params.oauth_consumer_key = this.consumerKey;
this.params.oauth_signature_method = 'HMAC-SHA1';
this.params.oauth_version = '1.0';
}
setOauthNonce(length, chars) {
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
return result;
}









share|improve this question


























    up vote
    0
    down vote

    favorite












    I have an ionic-angular app nkvshopapp with wordpress as backend. Wordpress is locally hosted with oauth1.0 plugin and oauth keys defined.



    Until yesterday morning, nkvshopapp was working fine and it displayed all of posts and categories from my wordpress website. It stopped working all of a sudden and now it displays error OAuth signature not defined. OAuth signature not defined error I double-checked OAuth keys and they were same as before (i.e. not regenerated anew). App`s index.html and config.ts both are same as before. My app is designed to load an additional Javascript (nkvshopapp.js) so I checked OAuth function within nkvshopapp.js too (in case anyone hacked my PC and made changes to it...getting paranoid, I know :)



    Finally, I double-checked in Postman if Oauth keys are being authenticated; and Postman does not display any error or warning. Call validation in Postman



    Am I missing anything? Any suggestions or pointers would be very helpful.
    Pls help.



    Here are extracts of index.html, config.ts and nkvshopapp.js.



    ./index.html:



    <!DOCTYPE html>
    <html lang="en" dir="ltr">
    <head>
    <meta charset="UTF-8">
    <title>NKVShop</title>
    <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">

    <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
    <link rel="manifest" href="manifest.json">
    <meta name="theme-color" content="#4e8ef7">

    <!-- add to homescreen for ios -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- cordova.js required for cordova apps -->
    <script src="cordova.js"></script>
    <script src="nkvshopapp.js"></script>

    </script>-->


    ./app/www/nkvshopapp.js:



    function OAuthSignature() {
    }

    OAuthSignature.prototype.generate = function (httpMethod, url, parameters, consumerSecret, tokenSecret, options) {
    var signatureBaseString = new SignatureBaseString(httpMethod, url, parameters).generate();
    var encodeSignature = true;
    if (options) {
    encodeSignature = options.encodeSignature;
    }
    return new HmacSha1Signature(signatureBaseString, consumerSecret, tokenSecret).generate(encodeSignature);
    //return new signatureBaseString;
    };

    // Specification: http://oauth.net/core/1.0/#anchor14
    // url: if the scheme is missing, http will be added automatically
    function SignatureBaseString(httpMethod, url, parameters) {
    //parameters = new ParametersLoader(parameters).get();
    this._httpMethod = new HttpMethodElement(httpMethod).get();
    this._url = new UrlElement(url).get();
    this._parameters = parameters;
    //this._parameters = new ParametersElement(parameters).get();
    this._rfc3986 = new Rfc3986();
    }

    SignatureBaseString.prototype = {
    generate : function () {
    // HTTP_METHOD & url & parameters
    return this._rfc3986.encode(this._httpMethod) + '&'
    + this._rfc3986.encode(this._url) + '&'
    + this._rfc3986.encode(this._parameters);
    }
    };


    ./src/providers/service/config.ts:



    import { Injectable } from '@angular/core';
    import { URLSearchParams } from '@angular/http';
    import { Headers } from '@angular/http';
    declare var oauthSignature: any;
    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    @Injectable()
    export class Config {
    url: any = 'http://127.0.1.1:8080/wordpress';
    consumerKey: any = 'Hl8XcAPgCqt6';
    consumerSecret: any = '3xGMKgiXBP7HoI2i9dkf3HByepZRSmSjYGQNszvXwzfOO0YW';
    oneSignalAppId: any = '';
    googleProjectId: any = '';
    language: any = 'english';
    appDir: any = 'ltr';

    appRateIosAppId: any = '12345678';
    appRateAndroidLink: any = '';
    appRateWindowsId: any = '12345678';
    shareAppMessage: any = 'download it';
    shareAppSubject: any = 'Hi';
    shareAppURL: any = '';
    shareAppChooserTitle: any = 'select app';
    supportEmail: any = 'nkvshopapp@gmail.com';

    oauth: any;
    signedUrl: any;
    randomString: any;
    oauth_nonce: any;
    oauth_signature_method: any;
    encodedSignature: any;
    searchParams: any;
    customer_id: any;
    params: any;
    options: any = {};
    constructor() {
    this.options.withCredentials = true;
    this.options.headers = headers;
    this.oauth = oauthSignature;
    this.oauth_signature_method = 'HMAC-SHA1';
    this.searchParams = new URLSearchParams();
    this.params = {};
    this.params.oauth_consumer_key = this.consumerKey;
    this.params.oauth_signature_method = 'HMAC-SHA1';
    this.params.oauth_version = '1.0';
    }
    setOauthNonce(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
    return result;
    }









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an ionic-angular app nkvshopapp with wordpress as backend. Wordpress is locally hosted with oauth1.0 plugin and oauth keys defined.



      Until yesterday morning, nkvshopapp was working fine and it displayed all of posts and categories from my wordpress website. It stopped working all of a sudden and now it displays error OAuth signature not defined. OAuth signature not defined error I double-checked OAuth keys and they were same as before (i.e. not regenerated anew). App`s index.html and config.ts both are same as before. My app is designed to load an additional Javascript (nkvshopapp.js) so I checked OAuth function within nkvshopapp.js too (in case anyone hacked my PC and made changes to it...getting paranoid, I know :)



      Finally, I double-checked in Postman if Oauth keys are being authenticated; and Postman does not display any error or warning. Call validation in Postman



      Am I missing anything? Any suggestions or pointers would be very helpful.
      Pls help.



      Here are extracts of index.html, config.ts and nkvshopapp.js.



      ./index.html:



      <!DOCTYPE html>
      <html lang="en" dir="ltr">
      <head>
      <meta charset="UTF-8">
      <title>NKVShop</title>
      <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
      <meta name="format-detection" content="telephone=no">
      <meta name="msapplication-tap-highlight" content="no">

      <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
      <link rel="manifest" href="manifest.json">
      <meta name="theme-color" content="#4e8ef7">

      <!-- add to homescreen for ios -->
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">

      <!-- cordova.js required for cordova apps -->
      <script src="cordova.js"></script>
      <script src="nkvshopapp.js"></script>

      </script>-->


      ./app/www/nkvshopapp.js:



      function OAuthSignature() {
      }

      OAuthSignature.prototype.generate = function (httpMethod, url, parameters, consumerSecret, tokenSecret, options) {
      var signatureBaseString = new SignatureBaseString(httpMethod, url, parameters).generate();
      var encodeSignature = true;
      if (options) {
      encodeSignature = options.encodeSignature;
      }
      return new HmacSha1Signature(signatureBaseString, consumerSecret, tokenSecret).generate(encodeSignature);
      //return new signatureBaseString;
      };

      // Specification: http://oauth.net/core/1.0/#anchor14
      // url: if the scheme is missing, http will be added automatically
      function SignatureBaseString(httpMethod, url, parameters) {
      //parameters = new ParametersLoader(parameters).get();
      this._httpMethod = new HttpMethodElement(httpMethod).get();
      this._url = new UrlElement(url).get();
      this._parameters = parameters;
      //this._parameters = new ParametersElement(parameters).get();
      this._rfc3986 = new Rfc3986();
      }

      SignatureBaseString.prototype = {
      generate : function () {
      // HTTP_METHOD & url & parameters
      return this._rfc3986.encode(this._httpMethod) + '&'
      + this._rfc3986.encode(this._url) + '&'
      + this._rfc3986.encode(this._parameters);
      }
      };


      ./src/providers/service/config.ts:



      import { Injectable } from '@angular/core';
      import { URLSearchParams } from '@angular/http';
      import { Headers } from '@angular/http';
      declare var oauthSignature: any;
      var headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
      @Injectable()
      export class Config {
      url: any = 'http://127.0.1.1:8080/wordpress';
      consumerKey: any = 'Hl8XcAPgCqt6';
      consumerSecret: any = '3xGMKgiXBP7HoI2i9dkf3HByepZRSmSjYGQNszvXwzfOO0YW';
      oneSignalAppId: any = '';
      googleProjectId: any = '';
      language: any = 'english';
      appDir: any = 'ltr';

      appRateIosAppId: any = '12345678';
      appRateAndroidLink: any = '';
      appRateWindowsId: any = '12345678';
      shareAppMessage: any = 'download it';
      shareAppSubject: any = 'Hi';
      shareAppURL: any = '';
      shareAppChooserTitle: any = 'select app';
      supportEmail: any = 'nkvshopapp@gmail.com';

      oauth: any;
      signedUrl: any;
      randomString: any;
      oauth_nonce: any;
      oauth_signature_method: any;
      encodedSignature: any;
      searchParams: any;
      customer_id: any;
      params: any;
      options: any = {};
      constructor() {
      this.options.withCredentials = true;
      this.options.headers = headers;
      this.oauth = oauthSignature;
      this.oauth_signature_method = 'HMAC-SHA1';
      this.searchParams = new URLSearchParams();
      this.params = {};
      this.params.oauth_consumer_key = this.consumerKey;
      this.params.oauth_signature_method = 'HMAC-SHA1';
      this.params.oauth_version = '1.0';
      }
      setOauthNonce(length, chars) {
      var result = '';
      for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
      return result;
      }









      share|improve this question













      I have an ionic-angular app nkvshopapp with wordpress as backend. Wordpress is locally hosted with oauth1.0 plugin and oauth keys defined.



      Until yesterday morning, nkvshopapp was working fine and it displayed all of posts and categories from my wordpress website. It stopped working all of a sudden and now it displays error OAuth signature not defined. OAuth signature not defined error I double-checked OAuth keys and they were same as before (i.e. not regenerated anew). App`s index.html and config.ts both are same as before. My app is designed to load an additional Javascript (nkvshopapp.js) so I checked OAuth function within nkvshopapp.js too (in case anyone hacked my PC and made changes to it...getting paranoid, I know :)



      Finally, I double-checked in Postman if Oauth keys are being authenticated; and Postman does not display any error or warning. Call validation in Postman



      Am I missing anything? Any suggestions or pointers would be very helpful.
      Pls help.



      Here are extracts of index.html, config.ts and nkvshopapp.js.



      ./index.html:



      <!DOCTYPE html>
      <html lang="en" dir="ltr">
      <head>
      <meta charset="UTF-8">
      <title>NKVShop</title>
      <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
      <meta name="format-detection" content="telephone=no">
      <meta name="msapplication-tap-highlight" content="no">

      <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
      <link rel="manifest" href="manifest.json">
      <meta name="theme-color" content="#4e8ef7">

      <!-- add to homescreen for ios -->
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">

      <!-- cordova.js required for cordova apps -->
      <script src="cordova.js"></script>
      <script src="nkvshopapp.js"></script>

      </script>-->


      ./app/www/nkvshopapp.js:



      function OAuthSignature() {
      }

      OAuthSignature.prototype.generate = function (httpMethod, url, parameters, consumerSecret, tokenSecret, options) {
      var signatureBaseString = new SignatureBaseString(httpMethod, url, parameters).generate();
      var encodeSignature = true;
      if (options) {
      encodeSignature = options.encodeSignature;
      }
      return new HmacSha1Signature(signatureBaseString, consumerSecret, tokenSecret).generate(encodeSignature);
      //return new signatureBaseString;
      };

      // Specification: http://oauth.net/core/1.0/#anchor14
      // url: if the scheme is missing, http will be added automatically
      function SignatureBaseString(httpMethod, url, parameters) {
      //parameters = new ParametersLoader(parameters).get();
      this._httpMethod = new HttpMethodElement(httpMethod).get();
      this._url = new UrlElement(url).get();
      this._parameters = parameters;
      //this._parameters = new ParametersElement(parameters).get();
      this._rfc3986 = new Rfc3986();
      }

      SignatureBaseString.prototype = {
      generate : function () {
      // HTTP_METHOD & url & parameters
      return this._rfc3986.encode(this._httpMethod) + '&'
      + this._rfc3986.encode(this._url) + '&'
      + this._rfc3986.encode(this._parameters);
      }
      };


      ./src/providers/service/config.ts:



      import { Injectable } from '@angular/core';
      import { URLSearchParams } from '@angular/http';
      import { Headers } from '@angular/http';
      declare var oauthSignature: any;
      var headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
      @Injectable()
      export class Config {
      url: any = 'http://127.0.1.1:8080/wordpress';
      consumerKey: any = 'Hl8XcAPgCqt6';
      consumerSecret: any = '3xGMKgiXBP7HoI2i9dkf3HByepZRSmSjYGQNszvXwzfOO0YW';
      oneSignalAppId: any = '';
      googleProjectId: any = '';
      language: any = 'english';
      appDir: any = 'ltr';

      appRateIosAppId: any = '12345678';
      appRateAndroidLink: any = '';
      appRateWindowsId: any = '12345678';
      shareAppMessage: any = 'download it';
      shareAppSubject: any = 'Hi';
      shareAppURL: any = '';
      shareAppChooserTitle: any = 'select app';
      supportEmail: any = 'nkvshopapp@gmail.com';

      oauth: any;
      signedUrl: any;
      randomString: any;
      oauth_nonce: any;
      oauth_signature_method: any;
      encodedSignature: any;
      searchParams: any;
      customer_id: any;
      params: any;
      options: any = {};
      constructor() {
      this.options.withCredentials = true;
      this.options.headers = headers;
      this.oauth = oauthSignature;
      this.oauth_signature_method = 'HMAC-SHA1';
      this.searchParams = new URLSearchParams();
      this.params = {};
      this.params.oauth_consumer_key = this.consumerKey;
      this.params.oauth_signature_method = 'HMAC-SHA1';
      this.params.oauth_version = '1.0';
      }
      setOauthNonce(length, chars) {
      var result = '';
      for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
      return result;
      }






      wordpress angular ionic-framework oauth






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 13:51









      SamB

      134




      134





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249416%2ferror-oauth-signature-not-defined-with-ionic-angular-app%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249416%2ferror-oauth-signature-not-defined-with-ionic-angular-app%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)