-
Notifications
You must be signed in to change notification settings - Fork 232
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
token and client_id from InAppBrowser not persisted in ionic app on android #208
Comments
Woohoo I got it working! Turns out that when working with ionic and I assume it is the same with cordova, storing the tokens according to default behavior in the cookie does not work. However, once you configure it to work with localStorage it works great! |
@abhayastudios I'm still getting error, can you help me? My screen freeze at the 'Redirecting...' screen.
|
I created a new application and works. |
I have moved |
@aL3xa To fix the freeze I increased the timeout in the devise view https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/views/devise_token_auth/omniauth_external_window.html.erb. Create the view in your project but with 3000 milliseconds to test (line 31). |
@dtelaroli, thanks for the update, but I still get the freeze after increasing the timeout value. Apparently, 'use strict';
document.addEventListener('deviceready', function () {
window.open = window.cordova.InAppBrowser.open;
console.log('console.log works well');
}, false); The Angular config section is pretty straightforward: .config(function($authProvider, ENV){
$authProvider
.configure({
apiUrl: ENV.apiEndpoint,
omniauthWindowType: 'inAppBrowser',
storage: 'localStorage',
authProviderPaths: {
google: '/auth/google_oauth2',
facebook: '/auth/facebook',
twitter: '/auth/twitter',
osm: '/auth/osm'
}
});
}) Any ideas what may have caused "the freeze"? |
@aL3xa is it working if you debug at chrome? Can you find the logcat and chrome console for errors? I configured for tests in android emulator and chrome (If your code is working fine at chrome the problema is confirmed at inAppBrowser). It's possible test outside emulator to easy debugging (it's required configure your api account to localhost). I use the
Can you share one small project with your code connecting to an api test server? |
I haven't tried it in Chrome (yet), as I'm debugging on android v4.1.x, but weinre returns something that might come handy: Error in Success callbackId: InAppBrowser1226996874 : TypeError: Illegal constructor Update: I can confirm the bug on vanilla Cordova projects. I filed this one at #214. |
* merges with upstream * modifies gitignore * adds allow-navigation and modifies the way we use inAppBrowser stucj on redirect see lynndylanhurley/ng-token-auth#208 * adds scenario for logging in with facebook - no error handling * minor refactoring * generates resources to run emulator * cleans unused code in activitiesController * reverts back to use http and not https as api protocol for auth related requests * removes unused allow-navigation setting in config.xml
After reading the comment of @nbrustein here, I started to better understand the communication between ng-token-auth and the inAppBrowser. If I print the response from ng-token-auth's handleLoadStop function to the console I see that it contains the full user object including the auth_token and client_id (which corresponds to the last client_id in the database). Therefore I think I can conclude that the communication with InBrowserApp works fine and that the ionic app has access to the data.
However, any subsequent API requests to my server receive a 401 Not Authorized response. When I look at the request headers of those API requests I don't see any of the headers that Chrome on my laptop is sending to the server such as: access-token, client, expiry, token-type and uid.
If I print to the console the key and value of the persistData function when running on android and with InAppBrowser mode then immediately after the callback I see the correct data, e.g.:
However, on subsequent requests I see this:
I also see that it tries to save the auth_headers in a cookie because it enters the switch default of the persistData function. Therefore I assume that somehow saving data through ipCookie does not work properly on ionic/android.
The text was updated successfully, but these errors were encountered: