File tree 1 file changed +7
-2
lines changed
mlengine/online-prediction/src/main/java 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 30
30
import com .google .api .services .discovery .model .RestDescription ;
31
31
import com .google .api .services .discovery .model .RestMethod ;
32
32
import java .io .File ;
33
+ import java .util .ArrayList ;
34
+ import java .util .List ;
33
35
34
36
/*
35
37
* Sample code for sending an online prediction request to Cloud Machine Learning Engine.
@@ -61,8 +63,11 @@ public static void main(String[] args) throws Exception {
61
63
File requestBodyFile = new File ("input.txt" );
62
64
HttpContent content = new FileContent (contentType , requestBodyFile );
63
65
System .out .println (content .getLength ());
64
-
65
- GoogleCredential credential = GoogleCredential .getApplicationDefault ();
66
+
67
+ List <String > scopes = new ArrayList <>();
68
+ scopes .add ("https://www.googleapis.com/auth/cloud-platform" );
69
+
70
+ GoogleCredential credential = GoogleCredential .getApplicationDefault ().createScoped (scopes );
66
71
HttpRequestFactory requestFactory = httpTransport .createRequestFactory (credential );
67
72
HttpRequest request = requestFactory .buildRequest (method .getHttpMethod (), url , content );
68
73
You can’t perform that action at this time.
0 commit comments