title: How to get Access Code for Google Cloud Storage?
body: <p>I am trying to upload a image to google cloud storage from my AngularJS web app and to do the same i need the access code which is to be placed in Authorization header while requesting the upload. To get access token i had introduced an endpoint at server side which is developed in JAVA. My current code to get access token is like this</p>
  
  <pre><code>GoogleCredential credential = GoogleCredential.fromStream(new URL("HERE GOES URL OF MY SERVICE ACCOUNT JSON FILE").openStream());
  if (credential.createScopedRequired()) {
        Collection&lt;String&gt; scopes = StorageScopes.all();
        credential = credential.createScoped(scopes);
      }
  String token = credential.getAccessToken();
  log.log( Level.SEVERE, "5 "+token);
  </code></pre>
  
  <p>But in logs i am getting null.</p>
  
  <p>Why i am getting the JSON file from a URL is because when i put the JSON file in same package it raised java.security.AccessControlException. So, to avoid that i placed the file on google drive and generated the direct download link which is used in above code.</p>
  
  <p>I just want the access code and send it to web app so that upload can be initiated. Any help would be appreciated.</p>
  
  <p>Thank You</p>