Open 2014james opened 5 years ago
static UserCredentials fromResource(Context context, int resourceId) throws IOException, JSONException { InputStream is = context.getResources().openRawResource(resourceId); byte[] bytes = new byte[is.available()]; is.read(bytes); JSONObject json = new JSONObject(new String(bytes, "UTF-8")); return new UserCredentials( json.getString("client_id"), json.getString("credential"), json.getString("refresh_token") ); }
{ "refresh_token": "。。。", "token_uri": "https://accounts.google.com/o/oauth2/token", "client_id": "。。。", "client_secret": "。。。", "scopes": [ "https://www.googleapis.com/auth/assistant-sdk-prototype" ] } no credential field?why
I solved it. I modified it like this, json. getString ("client_id"). // json. getString ("credential"), Json. getString ("client_secret"), Json. getString ("refresh_token")
static UserCredentials fromResource(Context context, int resourceId) throws IOException, JSONException { InputStream is = context.getResources().openRawResource(resourceId); byte[] bytes = new byte[is.available()]; is.read(bytes); JSONObject json = new JSONObject(new String(bytes, "UTF-8")); return new UserCredentials( json.getString("client_id"), json.getString("credential"), json.getString("refresh_token") ); }
{ "refresh_token": "。。。", "token_uri": "https://accounts.google.com/o/oauth2/token", "client_id": "。。。", "client_secret": "。。。", "scopes": [ "https://www.googleapis.com/auth/assistant-sdk-prototype" ] } no credential field?why