authentication - Error with Endpoints in Android : GoogleAuthIOException -
i have problem project, want connect google cloud endpoints android. i'm still getting same error:
05-12 21:50:23.995: w/system.err(17739): com.google.api.client.googleapis.extensions.android.gms.auth.googleauthioexception 05-12 21:50:23.995: w/system.err(17739): @ com.google.api.client.googleapis.extensions.android.gms.auth.googleaccountcredential$requesthandler.intercept(googleaccountcredential.java:224) 05-12 21:50:24.000: w/system.err(17739): @ com.google.api.client.http.httprequest.execute(httprequest.java:888) 05-12 21:50:24.000: w/system.err(17739): @ com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeunparsed(abstractgoogleclientrequest.java:407) 05-12 21:50:24.000: w/system.err(17739): @ com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeunparsed(abstractgoogleclientrequest.java:340) 05-12 21:50:24.000: w/system.err(17739): @ com.google.api.client.googleapis.services.abstractgoogleclientrequest.execute(abstractgoogleclientrequest.java:458) 05-12 21:50:24.000: w/system.err(17739): @ com.example.endpointstutorial_android.mainactivity$queryscorestask.doinbackground(mainactivity.java:74) 05-12 21:50:24.005: w/system.err(17739): @ com.example.endpointstutorial_android.mainactivity$queryscorestask.doinbackground(mainactivity.java:1) 05-12 21:50:24.005: w/system.err(17739): @ android.os.asynctask$2.call(asynctask.java:287) 05-12 21:50:24.005: w/system.err(17739): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:305) 05-12 21:50:24.005: w/system.err(17739): @ java.util.concurrent.futuretask.run(futuretask.java:137) 05-12 21:50:24.005: w/system.err(17739): @ android.os.asynctask$serialexecutor$1.run(asynctask.java:230) 05-12 21:50:24.005: w/system.err(17739): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076) 05-12 21:50:24.005: w/system.err(17739): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569) 05-12 21:50:24.005: w/system.err(17739): @ java.lang.thread.run(thread.java:856) 05-12 21:50:24.005: w/system.err(17739): caused by: com.google.android.gms.auth.googleauthexception: unknown 05-12 21:50:24.005: w/system.err(17739): @ com.google.android.gms.auth.googleauthutil.gettoken(unknown source) 05-12 21:50:24.005: w/system.err(17739): @ com.google.api.client.googleapis.extensions.android.gms.auth.googleaccountcredential.gettoken(googleaccountcredential.java:192) 05-12 21:50:24.010: w/system.err(17739): @ com.google.api.client.googleapis.extensions.android.gms.auth.googleaccountcredential$requesthandler.intercept(googleaccountcredential.java:217) 05-12 21:50:24.010: w/system.err(17739): ... 13 more`
my android code:
public class mainactivity extends activity { private static final string pref_account_name = "pref.account.name"; public static final string audience = "server:client_id:660102392535.apps.googleusercontent.com"; sharedpreferences settings; googleaccountcredential credential; string accountname; static final int request_account_picker = 2; myendpoint service; void chooseaccount() { startactivityforresult(credential.newchooseaccountintent(), request_account_picker); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); credential = googleaccountcredential .usingaudience( this,audience); settings = getsharedpreferences("safeandroid", 0); setaccountname(settings.getstring(pref_account_name, null)); myendpoint.builder builder = new myendpoint.builder( androidhttp.newcompatibletransport(), new gsonfactory(), credential); service = builder.build(); if (credential.getselectedaccountname() != null) { toast.maketext(getapplicationcontext(), "logged as: " + credential.getselectedaccountname(), 5000) .show(); sendrequest(); } else { chooseaccount(); } } private class queryscorestask extends asynctask<void, void, void> { context context; public queryscorestask(context context) { this.context = context; } protected void doinbackground(void... unused) { log.v("aaaaa", "2"); try { myentity e = service.myentity().get().execute(); log.v("aaaaa", e.tostring() + ""); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } return null; } } private void setaccountname(string accountname) { sharedpreferences.editor editor = settings.edit(); editor.putstring(pref_account_name, accountname); editor.commit(); credential.setselectedaccountname(accountname); this.accountname = accountname; } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); switch (requestcode) { case request_account_picker: if (data != null && data.getextras() != null) { string accountname = data.getextras().getstring( accountmanager.key_account_name); if (accountname != null) { setaccountname(accountname); sharedpreferences.editor editor = settings.edit(); editor.putstring(pref_account_name, accountname); editor.commit(); toast.maketext( getapplicationcontext(), "logged as: " + credential.getselectedaccountname(), 5000).show(); sendrequest(); } } break; } } private void sendrequest() { queryscorestask = new queryscorestask(this); a.execute(); } }
and endpoint code:
@api(name = "myendpoint", version = "v1",description = "this retrieves instance of myentity.", clientids = { "660102392535.apps.googleusercontent.com", "660102392535-dobseln3gde8e6lqnd2v80l3oh6mm1nh.apps.googleusercontent.com" }, audiences = { "660102392535.apps.googleusercontent.com" }) public class myendpoint { @apimethod(httpmethod = "get", name = "myentity.get", path = "myentity/get") public myentity getentity(user user) { mybusinessclass mybusinessclass = new mybusinessclass(); myentity myentity = mybusinessclass.getmyentity(); datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); entity device = new entity("gcmid", "keyname"); device.setproperty("account", user.getemail()); device.setproperty("device", "idtelefonu1"); datastore.put(device); return myentity; } }
i read people had problem, did not write how solve it. created new debug.key , new sha1 not work. tried create new android project new package - not worked.
are using adt on windows? if yes, sha1 fingerprint debug keystore can obtained in windows->preferences->android->build debug mode.
Comments
Post a Comment