Signup for the Ionic Newsletter to get the latest news and updates!

  • Santosh Shinde

    I have try to your steps for android but its not working , Please share your code on github..Thank you .

  • David Mauricio Jiménez López

    Hi, I follow your steps, but…

    • Luis Fernando Alves

      I have the same error… I wonder if anything changed with the Twitter API recently… Simon, please check if ur code is still working. I see that here in the comment section there are plenty of people getting errors…Maybe upload it to github to see what we are doing wrong…

  • David Mauricio Jiménez López

    Like on the phone run ionic run android

  • Jose Torres

    Thanks for the post, I’ve run into some errors which I hope you can help me with. I’m getting a token null error on the console when reloading and no app authentication either. Testing on the browser with ionic serve, is this the problem?

    • Andrew Sargison

      Hi, i am getting the same ‘null’ through the error handler on $cordovaOauth.twitter(… Did you manage to solve this? I am only testing using the emulator.

  • Satya

    Hi Simon
    I followed the tutorial, and the twitter login screen is not show up for me..
    Can you share the complete code on github please..!!

    • malaise

      have you download the good version of SHA ?
      bower install jsSHA#1.6.0

  • darrenkitlor

    For everyone below, a lot of native functionality involving ngCordova won’t display in your browser. You’ll need to push the tutorial directly to your device or run it in an emulator. ngCordova won’t run in Firefox, etc.

  • MisterJack49

    I’d like to import a feed in my app but without login the user, it would be a public feed, where you can see tweets without login in, like this one even disconnected I can see tweets

  • Simon Reimler

    Just wanted to let you know that I created a new version of this post where I simplified the Twitter integration process by using my created AngularJS library ngTwitter: http://blog:

  • Tadahiro Okamoto

    Thanks for the post, but how to debug the application using ng-cordova-oauth? Because we can’t use live reload server (it means that we can’t use “console.log”, right?) with ng-cordova-oauth.

  • Prakash

    But still i can not signup using twitter. It returns nothings. I have used ngcordova oauth

  • Sabin Hiworth

    is that possible to share a status without loggin in on twitter?

  • thulani mtetwa

    Please advise me on how to bypass authorisation of the application if I already have Access Tokens.

  • Naveen

    Hi, I am getting below error –

    services.js:26 Uncaught TypeError: Cannot read property ‘oauth_token’ of null

  • Naveen

    How can I fix it?

  • Carl

    thanks for the marvelous posting! I seriously enjoyed reading it, you happen to be a great author.I will remember to bookmark your blog and will come back in the future. I want to encourage yourself to continue your great posts, have a nice day! lucky patcher for ios

  • Jullios Cabillon

    i’m having issues when uploading image using POST API, this is the situation i got:

    in particular i’m posting an image with media_id on body request.

    I checked the code of the library, and what I understood is that even when make a POST call this part of code adds to url request the params (optional data):

    if (parameters !== {}) url = url + ‘?’ + $twitterHelpers.transformRequest(parameters);

    This solution is ok when url characters does not exceed the maximum numbers of characters on a HTTP call, but when media_id is too long the call fails.

    Could anybody can confirm this?

    This is the code i’m using but without success:

    var oauthObject = {
    oauth_consumer_key: clientId,
    oauth_nonce: $cordovaOauthUtility.createNonce(32),
    oauth_signature_method: “HMAC-SHA1”,
    oauth_token: token.oauth_token,
    oauth_timestamp: Math.round((new Date()).getTime() / 1000.0),
    oauth_version: “1.0”

    var signatureObj = $cordovaOauthUtility.createSignature(“POST”, url,
    oauthObject, {screen_name: token.screen_name}, clientSecret,

    $http.defaults.headers.common.Authorization = signatureObj.authorization_header;


    var _headers = {
    ‘Authorization’: signatureObj.authorization_header,
    ‘Content-Type’: ‘application/x-www-form-urlencoded’

    method: “post”,
    url: “”,
    data: JSON.stringify(base64String)
    }).success(function(data, status, headers, config) {
    .error(function(data, status, headers, config) {
    I have tested using both endpoint: (deprecated)
    This is the result i got:

    Request URL:
    Request Method:POST
    Status Code:401 Authorization Required
    Request Headers
    POST HTTP/1.1
    Accept: application/json, text/plain, /
    Origin: file://
    User-Agent: Mozilla/5.0 (Linux; Android 4.4.2; LG-V500 Build/KOT49I.V50020f) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/ Safari/537.36
    Authorization: OAuth oauth_consumer_key=”TG*********”,oauth_nonce=”yyBpmX9yienaHw0xe0izomB3Fp4zCQA0″,oauth_signature_method=”HMAC-SHA1″,oauth_token=”191362************”,oauth_timestamp=”1503497329″,oauth_version=”1.0″,oauth_signature=”M8cv3Att*********”
    Content-Type: application/json;charset=UTF-8
    Request Payloadview source
    media_data: “iv0 + long base64 string”
    Response Headers
    content-type:application/json; charset=utf-8
    date:Wed, 23 Aug 2017 14:08:47 GMT
    x-xss-protection:1; mode=block

    Thank you in advance.