nxtbgthng / OAuth2Client

Client library for OAuth2 (currently built against draft 10 of the OAuth2 spec)
855 stars 217 forks source link

I'm trying to authenticate with GitHub #104

Closed JZ-at-TP closed 10 years ago

JZ-at-TP commented 10 years ago

I've got it setup as:

[[NXOAuth2AccountStore sharedStore] setClientID:@"CLIENT" secret:@"SECRET" scope:[NSSet setWithObjects:nil] authorizationURL:[NSURL URLWithString:@"https://github.com/login/oauth/authorize"] tokenURL:[NSURL URLWithString:@"https://github.com/login/oauth/access_token"] redirectURL:[NSURL URLWithString:@"http://dashboard.goonies3.com/auth/github/callback"] forAccountType:@"GitHub"];

but when I try to auth with:

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

I keep getting:

*\ Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No token from token response: {"error":"bad_verification_code"}'

What am I doing wrong?

toto commented 10 years ago

You are hitting an assertion (try adding a symbolic breakpoint on -[NSException raise] to see where exactly - NXOAuth2AccessToken.m in this case).

It seems Github does not support the OAuth2 username/password flow. Try the external browser method.

JZ-at-TP commented 10 years ago

Hmm. When I try auth external browser method with [[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"GitHub"]; I get:

2014-01-28 13:30:26.686 Dashboard[72249:70b] -[NSURL nxoauth2_URLByAddingParameters:]: unrecognized selector sent to instance 0x8aa6e50 2014-01-28 13:30:26.690 Dashboard[72249:70b] *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL nxoauth2_URLByAddingParameters:]: unrecognized selector sent to instance 0x8aa6e50'

So I'm not sure what's going on.