Twitter login without social structure

I am trying to implement twitter login in my ios app. I don't want to use social personnel work. I've tried all the Twitter login ways, but unfortunately it doesn't work. Basically I ran into the issue of the callback url in it. Can you guys help me.

I tried this url too

http://codegerms.com/login-with-twitter-example-with-ios-tutorial-using-oauth/

but mostly I ran into a callback problem. Can anyone suggest another plugin.

+3


source to share


2 answers


To get information about a user from Twitter, you can use the OAuth.io iOS SDK: https://github.com/oauth-io/oauth-ios

By creating an account at https://oauth.io and adding Twitter as a provider, you can get user information quite easily. You just need to follow these steps:

1 Install the framework via Cocoa Pods or manually

Via Cocoa pod:

$ pod install "OAuth.io"

      

Manually:

Just download the OAuthiOS.framework

file here and install it like you would any other framework.

2 Insert the title link

Add #import <OAuthiOS/OAuthiOS.h>

to your ViewController.

3 Set the view controller as a delegate to the OAuthIODelegate:

@interface MyViewController : UIViewController<OAuthIODelegate>
//[...]
@end

      

4 Initialize and run the authentication popup in the ViewController:



OAuthIOModal *oauthioModal = [[OAuthIOModal alloc] initWithKey:@"your_app_public_key" delegate:self];
[oauthioModal showWithProvider:@"twitter"];

      

5 Implement the following delegate method to get a request object that allows you to get information about the user thanks to the method me

:

- (void)didReceiveOAuthIOResponse:(OAuthIORequest *)request
{
    [_request me:nil success:^(NSDictionary *output, NSString *body, NSHTTPURLResponse 
    *httpResponse)
     {
         NSLog(@"name: %@", [output objectForKey:@"name"]);
     }];
}

      

For more information on the iOS SDK, check out the tutorial here:

https://oauth.io/getting-started?ios&None

You can also check out the git tutorial:

https://oauth.io/docs/tutorials/client/ios

And find the SDK reference documentation here:

https://oauth.io/docs/api-reference/client/ios

Note that OAuth.io also opens the original core in the oauthd project (look at the repo here: https://github.com/oauth-io/oauthd )

Hope it helps :)

+2


source


rmaddy you can elaborate on what problem you are facing, I also followed this tutorial and successfully, I get an access token, try putting a breakpoint in your code. You may not have changed the callback url in the code, let me explain a little image to you

You must first put a breakpoint in the following function

  • (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType


Now launch the app and enter your credentials. After you have successfully received the request token, you will be redirected to your redirect url and then you will receive an access token enter image description here

You should not go into this if condition, try changing this code to your callback string. If you still have a problem, please let me know in detail, I will help you solve this problem.

0


source







All Articles