Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Request failed: unauthorized (401) #6

Open
oosswwaalldd opened this issue Oct 3, 2017 · 14 comments
Open

Error: Request failed: unauthorized (401) #6

oosswwaalldd opened this issue Oct 3, 2017 · 14 comments

Comments

@oosswwaalldd
Copy link

oosswwaalldd commented Oct 3, 2017

Hi this error -> Request failed: unauthorized (401) when you try the login() method.
I installed everything according to the docs. Please, I need to fix this, all users are gonna be compromised y this plugin stops working. Here my "ionic info" output:

cli packages:

@ionic/cli-plugin-cordova       : 1.5.0 (/Users/tuity/cross_platform/xxx/mobile/node_modules/@ionic/cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (/Users/tuity/cross_platform/xxx/mobile/node_modules/@ionic/cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (/Users/tuity/cross_platform/xxx/mobile/node_modules/@ionic/cli-utils)
ionic (Ionic CLI)               : 3.6.0 (/Users/tuity/cross_platform/xxx/mobile/node_modules/ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : ios 4.4.0
Ionic Framework    : ionic-angular 3.3.0

System:

Android SDK Tools : 25.2.2
Node              : v7.1.0
OS                : macOS High Sierra
Xcode             : Xcode 9.0 Build version 9A235
ios-deploy        : 1.9.2
ios-sim           : 6.1.2
npm               : 3.10.9
@husmen73
Copy link

husmen73 commented Oct 6, 2017

I have same problem.

@adebonis
Copy link

adebonis commented Nov 1, 2017

We have 2 projects now stuck - any chance of getting a fix for this?

@adebonis
Copy link

adebonis commented Nov 8, 2017

So based on this link its an iOS11 issue - iOS 11 no longer supports using Twitter through the built-in social framework. Instead, you can use Twitter Kit 3 to Tweet, log in users, and use the Twitter API.

https://dev.twitter.com/twitterkit/ios/migrate-social-framework

Can this plugin be reworked to use Twitter Kit 3?

This is important to have a working twitter component

@oosswwaalldd
Copy link
Author

Should be tag some of the admin guys so they can address this issue, I really need this plugin in my project

@adebonis
Copy link

So does the Pull Request solve the problem? Says its to use Twitter Kit 3 but its really only a plist file change.... #7

Any help here would be greatly appreciated - customer still waiting...

@chroa
Copy link
Owner

chroa commented Feb 18, 2018

Sorry for the wait. I think that issue is related to your settings in the twitter app you've created. Fill in the Callback URL with "http://localhost:4000" and it should work.

@bogdanfinn
Copy link

bogdanfinn commented May 3, 2018

Thanks @chroa.

Worked for me with my ios App.

@b-d-m-p
Copy link

b-d-m-p commented May 7, 2018

I'm still getting this issue even after adding the http://localhost:4000. I've set up it up according to the readme. The Twitter Kit 3 fix is merged into master, yeah?

In xcode I am getting this error:

2018-05-07 12:23:05.868262+0900 myapp[355:24853] THREAD WARNING: ['TwitterConnect'] took '15.179688' ms. Plugin should use a background thread.
2018-05-07 12:23:05.885847+0900 myapp[355:24853] CDVWKWebViewEngine: handleStopScroll
2018-05-07 12:23:06.335965+0900 myapp[355:26293] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "https://api.twitter.com";
    srvr = "api.twitter.com";
    sync = syna;
}
2018-05-07 12:23:06.514489+0900 myapp[355:24853] error: Request failed: unauthorized (401)
2018-05-07 12:23:06.525435+0900 myapp[355:24853] Request failed: unauthorized (401)

Any ideas?

@bogdanfinn
Copy link

bogdanfinn commented May 8, 2018

@b-d-m-p
i read somewhere that you have to enable keychain access in the config.xml. But i dont know if this solves your problem.

<platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="KeychainAccessibility" value="WhenUnlocked" />
        <preference name="deployment-target" value="7.0" />
    </platform>

@b-d-m-p
Copy link

b-d-m-p commented May 9, 2018

@bogdanfinn Unfortunately, that isn't working for me. One of the photo plugins I am using doesn't like that 7.0 and won't build with it. If I change it to 8.0, I can build but I am still getting the same 401 unauthorized issue. Any ideas?

@bogdanfinn
Copy link

bogdanfinn commented May 9, 2018

@b-d-m-p
Here is my configuration:

config.xml:

<preference name="TwitterConsumerKey" value="myKey" />
<preference name="TwitterConsumerSecret" value="mySecret" />
...
<plugin name="twitter-connect-plugin" spec="^0.6.0">
     <variable name="FABRIC_KEY" value="myFabricKey" />
</plugin>

package.json:
under dependencies:

"@ionic-native/twitter-connect": "^4.5.2",
"twitter-connect-plugin": "^0.6.0",

under plugins:

"twitter-connect-plugin": {
        "FABRIC_KEY": "myFabricKey"
},

Make sure that your Fabric Key is in the correct structure in your .plist File of your generated xcode project.

I attached my App Settings for the Twitter App:
bildschirmfoto 2018-05-09 um 09 45 49

And here is my function for the twitter login:

// In the constructor of the class: private tw: TwitterConnect
doTwitterLogin() {
    let env = this;

    this.tw.login().then(function (result) {
     //Logged in 
     env.tw.showUser().then(function (user) {
      //Loaded Profile
      }, (error) => {
        console.log(error);
      });
    }, (error) => {
      console.log(error);
    });
  }

@b-d-m-p
Copy link

b-d-m-p commented May 9, 2018

@bogdanfinn Dude, you saved my life. I don't know exactly what was wrong, but following your set up made it work. I think it was either the way the config.xml file was laid out or setting "Call back URL Locked" to "No" that did it. Thank you so much.

@bogdanfinn
Copy link

I am glad that I could help you :)
I searched a few hours on the internet how to solve it and at some point i get it to work with that configuration. I dont remember where i read about the "Locked" to "No"....

Maybe the Readme of this project should be updated for the future...

@b-d-m-p
Copy link

b-d-m-p commented May 10, 2018

Well, one thing was when you install the plugin with the key & secret --variables, it puts them inside <plugin name="twitter-connect-plugin" spec="^0.6.0">, and it is working with them outside like your's. So, it didn't occur to me to take them out because the plugin put them there. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants