Giter Club home page Giter Club logo

oauth2client's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oauth2client's Issues

Problem using [NSString nxoauth2_stringWithUUID]

I'm using the latest version of OAuth2Client on the master branch with a project and I'm running into a strange issue that I can't figure out. When I call [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:username:password:] and the request succeeds, the app crashes with error +[NSString nxoauth2_stringWithUUID]: unrecognized selector sent to class 0xc63fd8.

I figured out this is from line 52 of NXOAuth2Account.m, identifier = [NSString nxoauth2_stringWithUUID]; It seems the runtime can't find the NXOAuth2 category added to NSString, even though I followed the instructions in the README and added the OAuth2Client project to the build dependencies list, the linker list, and added OAuth2Client/** to the header search path. In fact, Xcode seems to be able to find that category. If I right click on the method call and choose "Jump to definition", Xcode shows me exactly where it is in NSString+NXOAuth2.m. Yet somehow when I run the program, that selector can't be found. Any idea what could be causing this?

[NXOAuth2PostBodyStream open] Stream has been reopened after close

I'm developing an ios application.

In my appdelegate i have:

  • (void)initialize;
    {
    [[NXOAuth2AccountStore sharedStore] setClientID:@".....t"
    secret:@"...."
    authorizationURL:[NSURL URLWithString:@"http://XXX/oauth/authorize"]
    tokenURL:[NSURL URLWithString:@"http://XXX/oauth/token"]
    redirectURL:[NSURL URLWithString:@"http://XXX"]
    forAccountType:@"myFancyService"];
    }

and in a view controller i have a button that calls:

  • (IBAction)buttonPressed:(id)sender {

    [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"
    username:@"XXX"
    password:@"XX"];
    }

But i get in the log the following message:

[NXOAuth2PostBodyStream open] Stream has been reopened after close

any idea?

Changes required to work as static framework target

Hi,
I've just added OAuth2Client to my project and had to make the following changes to get it to compile as a static framework and be seen by the mail project.

  1. Change the Public Headers Folder Path to include/${TARGET_NAME} (so it becomes include/OAuth2Client. This change allows me to do #import <OAuth2Client/NXOAuth2.h> in header files to bring it in.
  2. Changes all headers to be public rather than project. Otherwise they would not be seen by the projects.

Support for "Authorization: Bearer" Token Format

The framework worked correctly for me with SoundCloud, but when I tried WordPress, the response always returned Error 403. It turns out that WordPress requires the token in the HTTP header to be prefixed with "Authorization: Bearer " instead of "Authorization: OAuth ".

I finally got it to work with WordPress by adding a patch to the NXOAuth2Connection.m file, within the createConnection method at this statement:

oauthAuthorizationHeader = [NSString stringWithFormat:@"OAuth %@", client.accessToken.accessToken];

The patch tests the request URL hostname for the string "wordpress". In that case, it uses "Bearer " instead of "OAuth ":

- (NSURLConnection *)createConnection;
   ...
        NSString *host = request.URL.host;
        NSRange range = [host rangeOfString:@"wordpress"];
        if (range.location != NSNotFound) {
            oauthAuthorizationHeader = [NSString stringWithFormat:@"Bearer %@", client.accessToken.accessToken];
        }
        else {
            oauthAuthorizationHeader = [NSString stringWithFormat:@"OAuth %@", client.accessToken.accessToken];
        }
   ...

This works for me, but of course it's not a very good way of doing it. Is there some other way to configure the Authorization string format, depending on whatever the different services may require?

Missing ability to define flow type?

Using [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"]; I cannot configure the type of client I am using, which is required by the OAuth2 server I'm trying to interact with (37Signals) An example request would be the following:

https://launchpad.37signals.com/authorization/new?type=web_server&client_id=your-client-id&redirect_uri=your-redirect-uri

Where type could be web_server or user_agent. Is that available using this library?
Relevant OAuth2 spec: http://tools.ietf.org/html/draft-ietf-oauth-v2-26#section-2.1

Can't get this working out of the box : missing redirect_uri parameter and Stream has been reopened after close

I just grabbed this library from git, followed the instructions as per the documentation.

I provided my App's Facebook oauth authorize and token URLs, plus the key and secret. I also provided a redirect URL with a custom iOS URL scheme for good measure. I am attempting to get a token by passing a username and a password:

[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"facebook"
                                                          username:self.userName.text
                                                          password:self.password.text];

I get the following error when I submit this:

2013-05-27 19:32:03.448 OAuthProto[7342:511b] -[NXOAuth2PostBodyStream open] Stream has been reopened after close
2013-05-27 19:32:03.719 OAuthProto[7342:c07] oauthConnection Error: {"error":{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191}}

I registered the notification handlers you have in the documentation for both success and failure but neither of them are invoked.

Installing on Xcode 4 for OSX - Can't find foundation headers

I've been trying to install the framework to work on OSX and for some reason it is telling me when it builds the target framework:

"Warning: The specified SDK “Current Mac OS” does not appear to have all of the necessary headers installed. Update your project to use a built-in SDK (“Latest Mac OS” is recommended) or install the system headers (included with the “Command Line Tools” package) from the “Downloads” pane in the Xcode preferences."

Warning: no rule to process file '$(SDKROOT)/System/Library/Frameworks/Foundation.framework' of type wrapper.framework for architecture x86_64

Warning: no rule to process file '$(SDKROOT)/System/Library/Frameworks/Foundation.framework' of type wrapper.framework for architecture i386

And this when it compiles the project:

/Users/....../OSX/github/Sources/OAuth2Client_Prefix.pch:15:34: error: Foundation/Foundation.h: No such file or directory

(Linking to where the project is cloned to).

Anyone know why this might be happening?

what am I doing wrong?

I'm following the directions on the landing page to a T. I'm getting an http 400 error of "{"error":"invalid_request","error_description":"client_id and client_secret required"}"

I used the

-[NXOAuth2AccountStore setClientID:secret:authorizationURL:tokenURL:redirectURL:forAccountType:]

tried putting it in multiple places, AppDelegate, then in the ViewController itself.

I am using this method for login:

[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"
                                                       username:aUserName
                                                       password:aPassword];

I then registered with NotificationCenter for failure and success. It's obviously hitting the failure and I'm NSLogging to the console what the error is.

Although I am supplying the client_id which meetup.com is giving me in my OAuth2 Consumer information as the Key, and the secret being the secret they gave me.

I'm inputing my user and pass to meetup.com and I'm positive it's correct.

Is the Key that they give me not the client_id? If not what do I use for client_id?

Here's the complete log in console, some of this may help:

2012-12-25 23:58:35.848 MeetupTests[13292:3903] -[NXOAuth2PostBodyStream open] Stream has been reopened after close
2012-12-25 23:58:36.292 MeetupTests[13292:c07] oauthConnection Error: {"error":"invalid_request","error_description":"client_id and client_secret required"}

Request token with URL encoding [meetup]

I'd like to use OAuth2Client to connect to meetup.com using the "External Browser" method. This means that I get a redirect URI callback with a code, which then I need to use to get the token. I believe I need to use [[NXOAuth2AccountStore sharedStore] handleRedirectURL:url] to do this.

As per the meetup.com web site, I need to "make an HTTP application/x-www-form-urlencoded encoded POST request" to get the token (full details here: http://www.meetup.com/meetup_api/auth/ ).

It seems that [[NXOAuth2AccountStore sharedStore] handleRedirectURL:url] uses form encoding, not URL encoding, when it sends the request to get the token. Interestingly the NXOAuth2Connection:applyParameters method, which is used to prepare the token request, can do both URL and form encoding, but for POST requests it always uses the latter.

I was actually able to make the token request work by forcing the NXOAuth2Connection:applyParameters method to always do URL encoding, but obviously this is just a quick hack, not a long term solution.

Is there a parameter somewhere that I could set to achieve the same result? Or is this option missing from the library?

Thanks,
Peter

It doesn't do anything :(

Hi,

I have followed all the instructions and it doesn't work. The app builds perfectly fine, but literally nothing happens...

I am trying to connect to Instagram via OAuth 2.0, I thought this library would help/

Please help. Thanks. Here is my code:

-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

/*[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"instagram"
                               withPreparedAuthorizationURLHandler:^(NSURL *preparedURL){
                                   // Open a web view or similar
                               }];

 */

[self initialize];

[[NSNotificationCenter defaultCenter] addObserverForName:NXOAuth2AccountStoreAccountsDidChangeNotification
                                                  object:[NXOAuth2AccountStore sharedStore]
                                                   queue:nil
                                              usingBlock:^(NSNotification *aNotification){
                                                  // Update your UI

                                                  NSLog(@"Sucess");
                                                  webviewer.alpha = 0.0;
                                              }];


[[NSNotificationCenter defaultCenter] addObserverForName:NXOAuth2AccountStoreDidFailToRequestAccessNotification
                                                  object:[NXOAuth2AccountStore sharedStore]
                                                   queue:nil
                                              usingBlock:^(NSNotification *aNotification){
                                                  NSError *error = [aNotification.userInfo objectForKey:NXOAuth2AccountStoreErrorKey];
                                                  // Do something with the error

                                                  NSLog(@"Error: %@", error);
                                              }];

}

  • (void)initialize;
    {
    [[NXOAuth2AccountStore sharedStore] setClientID:@"ab6dc96859bf43b3a488199ec72d9964"
    secret:@"78aaaf1d99534bcb9cecbb09b3215580"
    scope:[NSSet setWithObjects:@"likes", @"relationships", @"comments", nil]
    authorizationURL:[NSURL URLWithString:@"https://api.instagram.com/oauth/authorize"]
    tokenURL:[NSURL URLWithString:@"https://api.instagram.com/oauth/access_token"]
    redirectURL:[NSURL URLWithString:@"myapp://instagram-callback"]
    forAccountType:@"Instagram"];

    // Access service:

    [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"Instagram"
    withPreparedAuthorizationURLHandler:^(NSURL *preparedURL){
    // Open a web view or similar

                                   [webviewer loadRequest:[NSURLRequest requestWithURL: preparedURL]];
    
                               }];
    

    }

set timeout interval

Hi,

I was wondering if it is possible to add a setTimeoutInterval function to NXOAuth2Request ? Or is there a other possibility for this?

barear

Dears,

i am receiving the access token as an object.

1- do you support this kind of response ?

{"value":"cc4774fd-cad5-4b23-a421-fe3bc4119d9c","expiration":1364369756252,"tokenType":"bearer","refreshToken":{"value":"f7789ff9-2fb4-4aaa-af6b-bcdd77217b74","expiration":1364343263731},"scope":["read","trust","write"],"additionalInformation":{},"expiresIn":2482,"expired":false}

2- if not can you tell me if you are going to support it ?

3- do you know any other library that support it ?

Cannot send anything other than strings in Params

If you pass in a dictionary containing anything other than NSStrings to +[NXOAuth2Request performMethod: onResource: usingParameters: withAccount:theAccount sendProgressHandler:] then NXOAuth2PostBodyPart triggers illegal type assertion.

Can never find NXOAuth2.h

Hello, I followed all the steps

  1. Had to track down my libOAuth2Client.a manually via the debug simulator build folder and drag it to the Debug folder where the OAuth2Client.framework was successfully placed

  2. Adding the "/tmp/OAuth2Client.dst/usr/local/include" to user header paths for both Target and Project, and both individually still nothing.

  3. Using Xcode 4.1, building to iOS 4.3 simulator

Could you please post a sample project with it linked properly for reference. I feel as though I have tried every possible variation of the instructions to get it working please help!

Thanks,

Kieran

Bug in NXOAuth2Client.m

NXOAuth2Client.m:133-136

Line 133: if there is no parameter key "error" in URL, then errorString is nil. In this case, the statement on line 136 will always return true because NSOrderedSame is enumerated to 0. An error object will be created and passed up to the app even though there is no error.

README missing add Security.framework

Just followed the README but in the end after copy-pasting the following code from the read me:

+ (void)initialize;
{
    [[NXOAuth2AccountStore sharedStore] setClientID:@"xXxXxXxXxXxX"
                                             secret:@"xXxXxXxXxXxX"
                                   authorizationURL:[NSURL URLWithString:@"https://...your auth URL..."]
                                           tokenURL:[NSURL URLWithString:@"https://...your token URL..."]
                                        redirectURL:[NSURL URLWithString:@"https://...your redirect URL..."]
                                     forAccountType:@"myFancyService"];
}

I got about 17 different "_SecTrustEvaluate" errors which interrupted the build.

Stumbled upon this http://stackoverflow.com/questions/5150982/iphone-sdk-paypal-integration-api when search for a solution - It suggested adding the Security.framework. After doing so I was able to complete the build successfully.

tl;dr Adding Security.framework to "Link Binary With Libraries" fixed above issue.

xcode 4

Does this work with x4? i'm having hard time installing framework on xcode 4.0.2 and 4.3 sdk. I do everying like in readme but still it won't link

Refreshing the access token.

Hi,

I'm writing an iOS app using this framework (installed through CocoaPods which is brilliant!)

I'm using the username/password flow and it works with no problems when the access_token is still valid.

I'm running the requests using [NXOAuth2Request performMethod:...] and I've followed through to see that this has built in token refreshing in it (i.e. if the token isn't valid it will try to refresh and try the connection again).

However, this isn't working for me all the time.

I've got the requests in an operation queue and I get a 401 error back. (Once the access token expires)

If I then restart the synchronisation process it will try to send the oauth refresh first. and then carry on with the sync.

Is this something that is know? I'm about to go code trawling to see if I can find the cause of this.

Thanks

Make NXOAuth2Connection pass along the response body

I envision something like this
- (id)initWithRequest:(NSMutableURLRequest *)request
requestParameters:(NSDictionary *)requestParameters
oauthClient:(NXOAuth2Client *)client
finish:(void (^)(NSData *data))finishBlock
fail:(void (^)(NSData *data, NSError *error))failBlock;

NXOAuth2AccountStore is undefined symbol

I followed the instructions in readme, and the app built successfully. Then I added:

[[NXOAuth2AccountStore sharedStore] setClientID:@"IDSTRING"
secret:@"SECRETSTRING"
authorizationURL:[NSURL URLWithString:@"https://domain/online/?q=oauth2/authorize/"]
tokenURL:[NSURL URLWithString:@"https://domain/online/?q=oauth2/authorize"]
redirectURL:[NSURL URLWithString:@"wm2://redirect"]
forAccountType:@"otiAnywhere"];

Now it provides the following error:

Undefined symbols for architecture i386:
"OBJC_CLASS$_NXOAuth2AccountStore", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have my app set for iOS 5 target .... is there a problem with iOS 5 in regards to this library?

Clear cache

It seems that when removing the accounts still leaves marks for access tokens etc. that another method has to be applied to wipe all cached data from oauth?
Because I still have other information stored after i perfrom this method:

for (NXOAuth2Account *account in [[NXOAuth2AccountStore sharedStore] accounts]) {
        [[NXOAuth2AccountStore sharedStore] removeAccount:account];
}

Thanks.

[iOS] Cannot run on the selected destination

Following the steps for setting up an iOS application, I'm getting the following error upon build:

The selected destination does not support the architecture for which the selected software is built. Switch to a destination that supports that architecture in order to run the selected software.

More information:

  • Deployment Target 5.0+ (tried 5.1 and 6.0 as well)
  • Devices iPhone
  • Build phases

build phases

  • Header Search Paths $(SRCROOT)/lib/OAuth2Client (recursive) (cloned as a git submodule to ./lib/OAuth2Client)

Getting started

The readme isn't working for me. I'm sure that I am just missing something minor, but I cannot figure it out.

  • drag the OAuth2Client.xcodeproj into your project: This step is pretty self-explanatory.
  • add OAuth2Client as a build dependency: Is this clicking on my project, going to Build Phases, and then Link Binary With Libraries and adding libOAuth2Client.a as required?
  • add OAuth2Client/** to your user header search path in the build settings: Build Settings, Header Search Paths, Recursive is checked and then says OAuth2Client after it, is that correct?
  • link your target against OAuth2Client (drag the OAuth2Client product from OAuth2Client.xcodeproj to your targets Link Binary With Libraries): I cannot figure out the difference between this and the 2nd step. I must have the 2nd step messed up.
  • #import "NXOAuth2.h": I get an error that says "File not found"

I read that you need to move the header files form project to public on the OAuth2Client build phases, which I did. Thanks.

Problems with Authorization for App.net

I am doing the normal mambo jambo oAuth dance with logging in etc and passing the redirect URL like that

[[NXOAuth2AccountStore sharedStore] handleRedirectURL:url];

Fine. Then I try to get a signed URL Request using this code:

NXOAuth2Request *theRequest = [[NXOAuth2Request alloc] initWithResource:[NSURL URLWithString:@"https://api.flattr.com/rest/v2/flattr"]
                                                                 method:@"POST"
                                                             parameters:nil];
theRequest.account = account;

NSMutableURLRequest* signedRequest = [[theRequest signedURLRequest] mutableCopy];

It works great with Flattr. When I am doing the same with App.net however, the Authorization header is malformed and uses OAuth instead of Bearer as type. This results in a 401 response. I can workaround that by fixing the header myself like

 [signedRequest setValue:[NSString stringWithFormat:@"Bearer %@", account.accessToken.accessToken] forHTTPHeaderField:@"Authorization"];

, but you may want to fix that.

Martin

How to get access_token for google API

Hi I was writing an app that I would like to use youtube API.

With the help of your open source, I have successfully get the code from something like this :http://localhost&code=...........

But here comes the problem, google doucmentation says I need to use POST request with the code attached and should be able to get a response which contains the access_taken, but when I use the following code

[NXOAuth2Request performMethod:@"POST"
onResource:[NSURL URLWithString:@"https://accounts.google.com/o/oauth2/token"]
usingParameters:@{@"code":code, @"grant_type":@"authorization_code"}
withAccount:nil
sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) {
}
responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error){
// Process the response
}];

The log says : [NXOAuth2PostBodyStream open] Stream has been reopened after close.

I just wonder if there's anything I missed or I was going the wrong direction ??
Thanks in advance!

oauthConnection error [37signals]

First thanks for the library - we use it in our app and it's great.

But we've received a couple of supports with this error. We got them all fixed by telling our users to sign out and sign in again but still it's a pain in the ass and I don't know how to debug it. All we see in the logs is thousands of this:

-[NXOAuth2PostBodyStream open] Stream has been reopened after close
oauthConnection Error: {"error":"Missing code query parameter."}

Any idea what's going on and how to fix it?

As said, if user logs out and logs in again, everything works fine. This should probably raise an exception or at least throw an error in responseHandler block.

NXOAuth2Request doesn't get a token.

Hi, I'm using a laravel-oauth2 server to send data to. But when I send a Get request to the server, the server says there's no token. It is the same as the google model. model. I've used this example : #26
loginflow
Here's my code

NXOAuth2Account *account = [[NXOAuth2AccountStore sharedStore] accountWithIdentifier:@"artpartIOS"];
  NSMutableDictionary *params = [NSMutableDictionary dictionary];

[params setObject: @"latitude" forKey: [NSString stringWithFormat:@"%f", location.latitude]];
[params setObject: @"longitude" forKey: [NSString stringWithFormat:@"%f", location.longitude]];
[params setObject: @"limit" forKey: @"5000"];
[params setObject: @"radius" forKey: @"5000"];

[NXOAuth2Request performMethod:@"GET"
                    onResource:[NSURL URLWithString:urlFormat]
               usingParameters:params
                   withAccount:account
           sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) {
               NSLog(@"%llu", bytesSend );
               NSLog(@"%llu", bytesTotal);
           }
               responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error){

                   NSString *resultString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

                   NSLog(@"FOUND:\n%@", resultString);
                   NSLog(@"ERROR:\n%@", error);

               }];

HTTPS with signed SSL certificate

Hi!

I don't undestand something about HTTPS with signed certificate:

I assume I have to do this :

[[NXOAuth2AccountStore sharedStore] setTrustModeHandlerForAccountType:@"myAccountType" block:^NXOAuth2TrustMode(NXOAuth2Connection connection,NSString hostname)
{
return NXOAuth2TrustModeSpecificCertificate;
}];

and something with this :

[[NXOAuth2AccountStore sharedStore] setTrustedCertificatesHandlerForAccountType:@"myAccountType" block:^NSArray*(NSString *hostname){
//What do I have to return there???????
}];

But what should I return in the block in setTrustedCertificatesHandlerForAccountType

Network error 1005 and Stream has been reopened.

Hi,

The network connection on the server and the device is working all the time, but still when i call the login method i get this error in the console. when i tap login the second time it always works, but on the first tap this error goes off.

oauthConnection Error:
Login failed: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo=0x7552230 {NSErrorFailingURLStringKey=https://www.mysite.com/register, NSErrorFailingURLKey=https://www.mysite.com/register, NSLocalizedDescription=The network connection was lost., NSUnderlyingError=0x72944c0 "The network connection was lost."}

And also every time that i press login i get that -[NXOAuth2PostBodyStream open] Stream has been reopened after close.

Using the latest lib.

Thanks.

can't exchange the code with a token

hi there,

i am using the explicit method
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"MyService"];

but after i come back from the safari using the redirection url sent from the server
your library is analyzing the url to extract the code number

sampleservice://?code=xxxx

when it start trying to contact the server to exchange the this code with a token i get this error

[NXOAuth2PostBodyStream open] Stream has been reopened after close

when i print the error in the notification i get:

Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x71a4080 {NSErrorFailingURLKey=https://10.2.165.201:8443/AuthServer/oauth/token, NSErrorFailingURLStringKey=https://10.2.165.201:8443/AuthServer/oauth/token}

any help is appreciated

Using OAuth2Client with Flickr - Extra step in Authentication Flow?

The framework is working beautifully for me with SoundCloud and WordPress. Thank you!

Now, I'm trying to add Flickr to my application's supported services, but they do things slightly differently and require getting an initial token before having the user authenticate as described here:

http://www.flickr.com/services/api/auth.oauth.html

I don't see a straightforward way of getting the OAuth2Client framework to do this extra step in the authentication flow. Am I missing something obvious?

No notifications were fired ?

I tried to test OAuth2Client with demo project (iPhone), using google-php oauth2 server, configured OAuth2Client and called:

[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"SampleService"];

Everything seems to be working fine ... I sniffed web traffic, app. opened webview, I approved access, it completed all oauth2 steps and in last step received code (access_token), which was valid (I tried to use it manually) but no notifications were fired.

NXOAuth2AccountStoreAccountsDidChangeNotification ?
NXOAuth2AccountDidFailToGetAccessTokenNotification ?

[[NSNotificationCenter defaultCenter] addObserverForName:NXOAuth2AccountStoreAccountsDidChangeNotification
                                                  object:[NXOAuth2AccountStore sharedStore]
                                                   queue:nil
                                              usingBlock:^(NSNotification *aNotification){
                                                    // Never called ? even when valid access token was received from token endpoint.
                                              }];

Am I missing something or should I parse manually received response from token endpoint to extract access token ?

What I did

I configured client with:

+ (void)initialize;
{
    [[NXOAuth2AccountStore sharedStore] setClientID:@"xXxXxXxXxXxX"
                                             secret:@"xXxXxXxXxXxX"
                                   authorizationURL:[NSURL URLWithString:@"https://...your auth URL..."]
                                           tokenURL:[NSURL URLWithString:@"https://...your token URL..."]
                                        redirectURL:[NSURL URLWithString:@"https://...your redirect URL..."]
                                     forAccountType:@"myFancyService"];
}

in app delegate,

Called [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"]; - client did all necessary steps to complete auth. process,

On success I should have received NXOAuth2AccountStoreAccountsDidChangeNotification or NXOAuth2AccountDidFailToGetAccessTokenNotification ...

Everything works but no notifications were fired/received. I need them to close webview and to continue using client for further requests.
Thank you.

2-legged request

Hi!

First of all congrats for your library, it's very well written :D.

I'm trying to use OAuth2Client to make authorized requests to a server with a custom-made OAuth (not FB/Twitter...). The problem is that I don't really know how to make a request to the server in 2-legged mode (mostly to register an user and log in, to obtain the access-token). i.e.: to register a user I have to POST the username, password, e-mail, etc... to an specific entry point, etc...

How should I do that using your library? I've seen that using FB,Twitter you make a call to the urls to log in, etc... But we'd need to have a custom login/register viewController in the project, so the registration/log flow should go to that screen and return to the app if the authorization process is complete.

Thanks a lot!

Kind regards.

Documentation in Readme is missing some important info

Hey Guys,

the Readme is rather helpful, but:

  • it doesn't describe the "User-agent flow" completely. It doesn't describe that you need to call openRedirectURL: after opening a WebView with authorizationURLWithRedirectURL: as URL
  • it doesn't describe the NXOAuth2Connection in a whole. The documentation says it's used like a normal NSURLConnection but it's more than that: Parameters, providing NSData, blocks, etc.

Thanks a lot for the helpful API and best regards,

Christian

access_token problems

I wrote all the code that is in the read me for logging in.

The successful login notification is called, so the login has worked.

I need to get the access_token - it should have been returned in some of the classes because the login was successful.

Question - how i can access that access_token from my class?

I see that it is in NXOAuth2Client class, but how do i get it in my class? I need to get it after the successful login notification to use it locally.

Thanks in advance. Looks like a great open source.

Possible addition to instructions

@nxtbgthng Just a quick suggestion:

I had some issues building my project after adding the OAuth2Client project using your instructions and eventually traced the issue to the fat I hadn't included "Security.framework" - it might be worth adding this to your instructions in case others have the same issue...

Thanks!

(Feel free to close this issue once you've read it)

UserData not being set

I am developing an app that uses the OAuth2Client library. At some point I add some user data to the keychain item, or so I believed. Here is the code:

NXOAuth2Account *account = [[NXOAuth2AccountStore sharedStore] accountWithIdentifier:accountID];

// ...

FMResultSet *savedAccount = [self.db executeQuery:@"select forename, surname, account_name, client_name, smallest_logo from accounts where account_name = ? limit 1", accountName];

if ([savedAccount next]) {
    createdAccount = [savedAccount resultDictionary];
    [account setUserData:createdAccount];
}

For some reason, when I retrieve the account, the user data is not set/available...

NSLog(@"Accounts: %@", [[NXOAuth2AccountStore sharedStore] accounts]);

And here is the output:

2013-04-15 00:12:06.583 Catapult[68429:c07] Accounts: (
    "<NXOAuth2Account identifier:'1E415A5E-2572-4FBE-A345-E01AAD18E5DD' accountType:'com.cataputlcentral.api' accessToken:<NXOAuth2Token token:184cf28aa6377fe82c4f58ca1078c52ba4e0b415d01f6599d6e56370c41f9196 refreshToken:ea6b6378fad1806157405f01396adb4389fad074779cabceb8172b6591915470 expiresAt:2013-04-15 00:12:06 +0000 tokenType: Bearer> userData:(null)>"
)

As you can see the userData attribute is nil...

APIs requiring token exchange parameters in query string

According to #72 and others there are APIs that do no accept the token request parameters in the POST form body. Such APIs are

  • LinkedIn
  • Facebook
  • ...add more...

It might be possible to add a configuration for such APIs that sends the parameters in the query string. But let's discuss this first, as those APIs are clearly not implementing the OAuth2 standard correctly. See the spec for more info:

The client makes a request to the token endpoint by sending the
following parameters using the "application/x-www-form-urlencoded"
format per Appendix B with a character encoding of UTF-8 in the HTTP
request entity-body

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.