AuthenticationViewController icon indicating copy to clipboard operation
AuthenticationViewController copied to clipboard

Can't receive access_token

Open AndreyMomot opened this issue 8 years ago • 8 comments

Does it work correctly fro Twitter/Facebook or Google+ ? Can't manage any of them. Can anyone provide an example with those networks? e.g. I have following url for twitter: "https://api.twitter.com/oauth/authorize/?client_id=(clientId)&scope=(scopes.joined(separator: "+"))&redirect_uri=(redirectURI)&response_type=code" accessTokenURL = https://api.twitter.com/oauth/access_token"

redirectURI = "https://www.google.com"

Then, I put my ClientID and Secret, but nothing works. I can login and do not receive my token after switching to redirectURL.

AndreyMomot avatar Dec 04 '17 14:12 AndreyMomot

Hi,

The redirect URL needs to be a callback to your app scheme, check the README instructions on how to setup your project https://github.com/raulriera/AuthenticationViewController/blob/master/README.md

raulriera avatar Dec 04 '17 14:12 raulriera

Still do not have an answer. Could anyone provide a workable example for Twitter, for example? Which url should I use for redirectURI and for requestToken there?

AndreyMomot avatar Dec 04 '17 16:12 AndreyMomot

I'm the creator of this library, I just said in the previous message what redirectURI to use. 🤔

raulriera avatar Dec 04 '17 16:12 raulriera

Yep, thank you. Now I can authenticate, but after that it opens redirect_uri and code from AppDelegate: (authenticationViewController.authenticateWithCode(code)) doesn't retrieve. What am I doing wrong? Doesn't work even with Instagram...

AndreyMomot avatar Dec 05 '17 12:12 AndreyMomot

Can you provide some code example?

raulriera avatar Dec 05 '17 14:12 raulriera

Here you can find it: https://github.com/AndreyMomot/AuthenticationViewController

I just can't get what to use for URL Scheme in my case.

AndreyMomot avatar Dec 05 '17 16:12 AndreyMomot

// Before doing this, you should check the url is your redirect-uri before doing anything. Be safe :)
if let components = URLComponents(url: url, resolvingAgainstBaseURL: false), let queryItems = components.queryItems, let code = queryItems.first?.value {

Have you checked that the URL you are getting here is the scheme you specified? Does it match the one you used in Instagram?

raulriera avatar Dec 05 '17 16:12 raulriera

Make you used OAuthExample://oauth-callback in your Instagram app and also that you are getting the same one in the AppDelegate (previous code snippet)

raulriera avatar Dec 05 '17 17:12 raulriera