[SOLVED] Method: signupUrls.create cannot be create

Issue

This Content is from Stack Overflow. Question asked by chitaranjan pradhan

code
:
403
message
:
“Caller is not authorized to manage project.”
status
:
“PERMISSION_DENIED”

<script src="https://apis.google.com/js/api.js"></script>
<script>
  /**
   * Sample JavaScript code for androidmanagement.signupUrls.create
   * See instructions for running APIs Explorer code samples locally:
   * https://developers.google.com/explorer-help/code-samples#javascript
   */

  function authenticate() {
    return gapi.auth2.getAuthInstance()
        .signIn({scope: "https://www.googleapis.com/auth/androidmanagement"})
        .then(function() { console.log("Sign-in successful"); },
              function(err) { console.error("Error signing in", err); });
  }
  function loadClient() {
    gapi.client.setApiKey("YOUR_API_KEY");
    return gapi.client.load("https://androidmanagement.googleapis.com/$discovery/rest?version=v1")
        .then(function() { console.log("GAPI client loaded for API"); },
              function(err) { console.error("Error loading GAPI client for API", err); });
  }
  // Make sure the client is loaded and sign-in is complete before calling this method.
  function execute() {
    return gapi.client.androidmanagement.signupUrls.create({
      "callbackUrl": "xxxxx",
      "projectId": "xxxxxxx"
    })
        .then(function(response) {
                // Handle the results here (response.result has the parsed body).
                console.log("Response", response);
              },
              function(err) { console.error("Execute error", err); });
  }
  gapi.load("client:auth2", function() {
    gapi.auth2.init({client_id: "YOUR_CLIENT_ID"});
  });
</script>
<button onclick="authenticate().then(loadClient)">authorize and load</button>
<button onclick="execute()">execute</button>

You have created a new client application that uses libraries for user authentication or authorization that will soon be deprecated. New clients must use the new libraries instead; existing clients must also migrate before these libraries are deprecated. See the Migration Guide for more information.



Solution

This issue can occurs if your project ID (ID of the Google Cloud Platform project which will own the enterprise) does not match to the account signed-in or vice versa. Another possibility is that the Android Management API may not have been enabled on the Google Cloud Platform project you are using.

Please double check your Cloud Platform project ID to ensure your authentication account is included and the proper APIs are enabled..

Note: The older Google Sign-In platform library: apis.google.com/js/platform.js, and Google APIs client library for Javascript: gapi.client are no longer supported for user authentication and authorization. They have been replaced by a single new Google Identity Services Javascript: account.google.com/gsi/client.

If you are building a server-based solution, you can create a service account so you don’t need to authorize the access every time.


This Question was asked in StackOverflow by chitaranjan pradhan and Answered by Rey V. Aquino It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?