I am trying to create a login page using google oAuth. For this i have created a clientID. In ClientID i have done created for Android since i believe i app would be running on an Android Device.
Create Client Id ->Installed Application -> Android
I have done keytooling and signed it with SHA1 and create a clientID
then i created a Public API Access. In this i have created an Android Key. I have provided the com name and SHA1 details. Since i am using an INTEL XDK it was easy to get the COM namespane from there.
In my javascript code i have done something like this to construct the URL.
var clientID ="client_id="; var responeType = "&response_type=code"; var scope ="&scope=profile"; var scope ="&scope=https://www.googleapis.com/auth/calendar.readonly"; var redirectURL ="&redirect_uri=urn:ietf:wg:oauth:2.0:oob"; var url ="https://accounts.google.com/o/oauth2/auth?"+clientID+responeType+scope+redirectURL+"&approval_prompt=auto";
then i have used an XHRRequest to give a call to this URL
var xhr = new XMLHttpRequest(); xhr.open("GET",url,false);
xhr.onload = function() { if(xhr.readyState==4 && xhr.status==200) {
console.log(this.response); var resp = this.response;} } xhr.onerror = function(e) { alert("Error : "+e) } xhr.send();
I have a button with event listener attached to it. I am new to android and especially to oAuth. I am getting all sort of errors such as
Please copy this code, switch to your application and paste it there:
when i click the button i do not see any login Page from google asking for permission but i can see data coming in console.log().
What is wrong that i am doing here.
If there are any way to create Hybrid APp using html5 please share. also please tell me if i am doing it write or wrong.Please guide me.
-S