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

Can't receive access_token #6

Open
AndreyMomot opened this issue Dec 4, 2017 · 8 comments
Open

Can't receive access_token #6

AndreyMomot opened this issue Dec 4, 2017 · 8 comments
Labels

Comments

@AndreyMomot
Copy link

AndreyMomot commented Dec 4, 2017

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.

@raulriera
Copy link
Owner

raulriera commented Dec 4, 2017

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

@AndreyMomot
Copy link
Author

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?

@raulriera
Copy link
Owner

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

@AndreyMomot
Copy link
Author

AndreyMomot commented Dec 5, 2017

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...

@raulriera
Copy link
Owner

Can you provide some code example?

@AndreyMomot
Copy link
Author

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

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

@raulriera
Copy link
Owner

// 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
Copy link
Owner

raulriera commented Dec 5, 2017

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)

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

No branches or pull requests

2 participants