Oauth.io phonegap social login (cannot find hostname in file:///)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 03:14:28

问题


I have included oauth.js file. I am initializing the oauth using following code

OAuth.initialize('public-key');
OAuth.popup('twitter', function(error, result) {
                console.log(result);
                //handle error with error
                //use result.access_token in your API request
                result.get('/1.1/account/verify_credentials.json').done(function(data) {
                    console.log(data)
                    alert('Hello ' + data.name)
                })
            });

Its properly working in browser but not in device.

I have tried to include following plugin in config.xml

<gap:plugin name="OAuth.io" value="com.phonegap.plugins.oauthio" version="0.1.1"/>

But i am getting "this plugin is not supported for phonegap" message at the time of creating the build in [https://build.phonegap.com/][1].

So I have removed that plugin and created the .apk file and executed in device. Its getting following error which is mentioned in screen shot.

Please guide me. Thanks.


回答1:


Did you check this out ? https://github.com/oauth-io/oauth-phonegap/issues/11

I think you are using the wrong plugin version. The best way to check this is print the result for OAuth.getVersion() and check whether it is the correct version you are using (phone gap version instead of the web version).




回答2:


1) Remove the reference to the oauthio js file from your html (phonegap will inject it)

2) Make sure you have included phonegap.js or cordova.js before everything.

3) Make sure that you are initialising the oauthio after the device ready event has been fired.

document.addEventListener('deviceready', function(){ OAuth.initialize('app_id'); }, false)



来源:https://stackoverflow.com/questions/22070242/oauth-io-phonegap-social-login-cannot-find-hostname-in-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!