Github API callback URL - ios

I'm trying to write a github client for iOS in Swift. So far I managed to understand how OAuth 2.0 works.
But the thing I don't understand is what callback URL should I enter (for user to be redirected after dealing with OAuth), when registering my app at OAuth applications list. I add URL scheme like "mycustomapp" in Info.plist, then I enter "mycustomapp://" in the callback url field on developer.github website, but it says, that this url is invalid. What URL should I use?

I've managed to find a solution to this issue on a oAuthSwift wiki page.
Some API do not accept custom url scheme (ex: myapp://) into callback URL (ex: Linkedin oauth v2, Twitter oauth v1), only http is accepted.
So I used a URL with http scheme, which redirects to my custom one.
I entered http://oauthswift.herokuapp.com/callback/myappname as a callback and inside my app I redirect to oauth-swift://oauth-callback/myappname
Code could be found here https://github.com/dongri/oauthswift.herokuapp.com

Related

Oauth2.0 Google API token issue - Error: redirect_uri_mismatch

I have trouble creating a Google API OAuth2.0 token though following all the steps here: [OAuth2 Authentication](
https://developers.google.com/adwords/api/docs/guides/authentication?authuser=1)
When trying to create the token through the OAuth2.0 playground:
OAUTH 2.0 playground
I end up with this error:
Discussion on similar threads tried to give some guidance but without any luck in my case.
Add google.com in the authorized domain list of your app's OAuth consent screen.
Click on the application for which you want to configure for the next step:
Make sure to also add 'https://developers.google.com' in the Authorized JavaScript origins and 'https://developers.google.com/oauthplayground' in the Authorized redirect URIs[click 'save' below once added]:
You are applying your own client id and client secret to Oauth2 playground you are also using browser credentials.
For browser credentials to work it must be able to return the token to an endpoint that can handle it and that endpoint (Redirect uri) must be registered in the Google Developer console for that project.
if you check your first picture under the check box you clicked
You will need to list the URL https://developers.google.com/oauthplayground as a valid redirect URI in your Google APIs Console's project. Then enter the client ID and secret assigned to a web application on your project below:
Try adding that URL as it says.

Cortana - OAuth2 Redirect URL Configuration not changing

I'm currently implementing an OAuth2 authentication using Microsoft Bot Framework and Cortana as one of my channels. However, as I was setting up my OAuth2 configuration with the following details in where I properly set the Redirect URL both from Knowledge Store and apps.dev.microsoft.com
Knowledge Store:
apps.dev.microsoft.com:
Whenever I authenticate to Cortana based from the OAuth2 that I've configured, the redirect URI seems to be always set as https://www.bing.com/agents/oauth. Here's a screenshot of the http request from Cortana Authentication that I got from fiddler:
Which causes this error message:
Any idea how to fix this?
Don't forget that the bot channel (in this case Cortana) needs to be where the redirect points to. Cortana's redirect is https://www.bing.com/agents/oauth.
Documentation here. You can test OAuth via botframework and the emulator. In that case, the redirect is https://token.botframework.com/.auth/web/redirect. Documentation here. If you look at the diagram in the spec on page 10, you'll see that Cortana is the client. The auth call needs to come back to her. You also need to let the auth server know that the redirect URL is allowed. For Microsoft login, you go to the app dev portal, select your app, go add a "web platform" and register the redirect urls. That should solve the problem on both ends.

Custom URL scheme for an iOS app with dropbox oauth2 authorization?

I'm trying to utilize dropbox with my Qt-based iOS app. My problem is the redirection from the dropbox authorization webpage back to the app.
I did not manage to get the dropbox authorization to work with the Qt WebView, so I am simply launching the default browser to the dropbox authorization site.
According to the dropbox dev portal, for the redirect_uri parameter, you can only use the https scheme for external addresses, and the http scheme for localhost addresses.
Does this make it impossible for the redirection to utilize a URL scheme that I have configured for my app, such as: 'myapp://' ?
How should I have dropbox redirecting back to my app? Should I use a custom website that redirects to my app using the URL scheme, or should I have my app as a server that listens to some port on localhost, so that I would use 'http://localhost:[port number]'? Suggestions? Are these even possible?
Can a URL scheme be used somehow in connection with a 'http://localhost' -based URL?
It is of course possible to omit the redirect_uri and let the user to copy the authorization code or token, switch back to my app, and paste it to a text field, but I think this would be a bit of a hassle to the user.
One important thing to note here is that the Dropbox API OAuth 2 implementation offers two different flows, "code" and "token". The code flow does require https://, unless it's a localhost URL, in which case it allows http:// or https:// (only).
You can use other protocols with the token flow though. Here are the variations broken out, with the result/error for each.
With redirect_uri:
code flow:
https://www.dropbox.com/1/oauth2/authorize?client_id=APP_KEY&response_type=code&redirect_uri=myapp://dropbox_callback
"Invalid redirect_uri: "myapp://dropbox_callback": When response_type=code, redirect_uri must start with "https://", unless it's a localhost URI."
https://www.dropbox.com/1/oauth2/authorize?client_id=APP_KEY&response_type=code&redirect_uri=myapp://localhost/dropbox_callback
"Invalid redirect_uri: "myapp://localhost/dropbox_callback": When response_type=code, localhost URIs may only start with "http://" or "https://"."
token flow:
https://www.dropbox.com/1/oauth2/authorize?client_id=APP_KEY&response_type=token&redirect_uri=myapp://dropbox_callback
200 (this is the version that probably makes the most sense for you to use)
Without redirect_uri:
code flow:
https://www.dropbox.com/1/oauth2/authorize?client_id=APP_KEY&response_type=code
200
token flow:
https://www.dropbox.com/1/oauth2/authorize?client_id=APP_KEY&response_type=token
"Missing redirect_uri (required when "response_type" is "token")"

Google OAuth 2.0 redirect_uri_mismatch error

I created a Google OAuth 2.0 ClientID and secret in Google Developer console
After that I tested in Google OAuth playground (https://developers.google.com/oauthplayground).
and registered ClientID and secret already created above and applied to Google OAuth 2.0 playground setting menu.
Some people say that after creating ClientID/secret they need some time for testing. So after two days I tried to test in the same conditions but the error is same redirect_uri_mismatch.
How can I solve this?
As little as having a '/' at the end of your uri and not having the same '/' at the end in your code will throw it off.
Your site URL and the Authorized redirect URIs in developer console should be the exact match.
This kind of error occurs if one URL has www (http://www.example.com) and the other URL is non-www (http://example.com).
Other common URI mismatch are:
Using http:// in Authorized Redirect URIs and https:// as actual URL, or vice-versa
Using trailing slash (http://example.com/) in Authorized Redirect URIs and not using trailing slash (http://example.com) as actual URL, or vice-versa
Here is the step-by-step procedure (with screenshots) to update the Authorized redirect URIs in Google Developer Console (For those like me who found it difficult to get to that page).
Go to https://console.developers.google.com
Select your Project
Click on the menu icon
Click on API Manager menu
Click on Credentials menu. And under OAuth 2.0 Client IDs, you will find your client name. In my case, it is Web Client 1. Click on it and a popup will appear where you can edit Authorized Javascript Origin and Authorized redirect URIs.
Here is a Google article on creating project and client ID.
It should be a exact match what you have given in the console.developers.com.
In my case I missed the www in the url.
For eg: you have given http://www.google.com but in console.developers.com you gave http://google.com
It will still throw error. So it should be exact match.
The redirect URI (where the OAuth response is returned to) has to be registered in Google APIs console, and the error is indicating that you haven't done that, or haven't done it correctly.
Go to the console for your project and look under API Access. You should see your client ID & secret there, along with a list of redirect URIs. If the URI you want isn't listed, click edit settings and add the URI to the list.
I kept getting this same error until I realized that I needed to put "signin-google" at the end of the redirect setting in the Google API console, like this (ie, NOT http://www.example.org/api):
http://www.example.org/api/signin-google
(Magento 1.*) if You use inchoo Social Connect Magento extension then:
Set below url in your google app (OAuth 2.0 client IDs):
Authorized Redirect URIs: http://www.example.com/socialconnect/google/connect/
Authorized JavaScript Origins: http://www.example.com
Don’t forget to replace http://www.example.com with your domain
Please make sure that in your google-client-api, the value of credentials in these field are matched as what you got from Google API console:
$client->setClientId('xxx.apps.googleusercontent.com');
$client->setClientSecret('xxx');
$client->setRedirectUri('http://example.com/oauth2callback');
$client->setDeveloperKey('xx');
This could happen when the value of setRedirectUri is different from the one you set in Google API console.

Google OAuth 2.0 Callback URL

I have an iOS application which authenticates with Google's servers via OAuth 2.0. I have just one problem, my app doesn't seem to respond to the callback URL. I have set the callback URL correctly in my code but no response.
I was just wandering if anyone knows how to change the callback URL on the Google OAuth API Console because right it is some random URL which doesn't seem to work for me:
urn:ietf:wg:oauth:2.0:oob
You can use the oob URI with an embedded view, or you can rely on the user to copy and paste the code.
But on iOS you have a better option, you can use a custom scheme based on the bundle id (or on the client id):
https://plus.google.com/111487187212167051233/posts/AztHNnQh7w6

Resources