davido / gerrit-oauth-provider

OAuth2 authentication provider for Gerrit Code Review. Please upload changes for review to: https://gerrit-review.googlesource.com/#/admin/projects/plugins/oauth
Apache License 2.0
140 stars 84 forks source link

bazel build oauth fail, no such package '@scribe//jar' #131

Closed wenchiching closed 5 years ago

wenchiching commented 5 years ago

I want to change the API in Office365Api.java from https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize to https://login.microsoftonline.com/common/oauth2/v2.0/authorize

so I git clone the gerrit source code and clone gerrit-oauth-provider into gerrit/plugins folder

I can "bazel build gerrit" build gerrit.war success and also "bazel build plugins/plugin-manager:plugin-manager" build pass but "bazel build plugins/oauth:oauth" fail, error message as below

$ bazel build plugins/oauth:oauth
INFO: Invocation ID: 0630d0bf-382e-42e9-b1b3-f35a33cc34ad
ERROR: /disk2/github/gerrit/plugins/oauth/BUILD:10:1: no such package '@scribe//jar': The repository '@scribe' could not be resolved and referenced by '//plugins/oauth:oauth__plugin'
ERROR: Analysis of target '//plugins/oauth:oauth' failed; build aborted: no such package '@scribe//jar': The repository '@scribe' could not be resolved
INFO: Elapsed time: 0.071s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

any idea how to deal with it?

davido commented 5 years ago

Have you checked the docs: [1]? Particularly, you need:

Put the external dependency Bazel build file into the Gerrit /plugins directory, replacing the existing empty one.

cd gerrit/plugins
  rm external_plugin_deps.bzl
  ln -s @PLUGIN@/external_plugin_deps.bzl .

For one plugin-manager is a core plugin, but for another this plugin doesn't have any third parties dependencies.

[1] https://gerrit.googlesource.com/plugins/oauth/+/refs/heads/master/src/main/resources/Documentation/build.md

wenchiching commented 5 years ago

didn't find the document there, thank you very much

davido commented 5 years ago

You are welcomed. Have you considered to upload the fix to the oauth plugin: [1], so that other users can benefit from it?

[1] https://gerrit-review.googlesource.com/admin/repos/plugins/oauth

wenchiching commented 5 years ago

change to common and get below error message, still study Azure docs and finding the root cause

[2019-09-27 08:08:45,567] [HTTP-87] ERROR com.google.gerrit.pgm.http.jetty.HiddenErrorHandler : Error in GET /oauth?code=M22ba1863-674c-610d-698c-80d7085425c5&state=vEIn0gGWetNHlW5IbI-XX7-XnLFhxeDIUqmgEQx
3EOs                                                                                                                                                                                                        
java.io.IOException: Status 401 ({                                                                                                                                                                          
  "error": {                                                                                                                                                                                                
    "code": "UnknownError",                                                                                                                                                                                 
    "message": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-e
quiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/>\r\n<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>\r\n<style type=\"text/css\">\r\n<!--\r\nbody{margin:0;f
ont-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}\r\nfieldset{padding:0 15px 10px 15px;} \r\nh1{font-size:2.4em;margin:0;color:#FFF;}\r\nh2{font-size:1.7em;margin:0;colo
r:#CC0000;} \r\nh3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} \r\n#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:\"trebuchet MS\", Verdana, sans-serif;color:#FFF;\r\nbackground-
color:#555555;}\r\n#content{margin:0 0 0 2%;position:relative;}\r\n.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}\r\n-->\r\n</style>\r\n</head>\r\n<body>\r\n<
div id=\"header\"><h1>Server Error</h1></div>\r\n<div id=\"content\">\r\n <div class=\"content-container\"><fieldset>\r\n  <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>\r\n  <h
3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>\r\n </fieldset></div>\r\n</div>\r\n</body>\r\n</html>\r\n",                                       
    "innerError": {                                                                                                                                                                                         
      "request-id": "a155227c-f9b5-4adb-a402-ad2267bde5e1",                                                                                                                                                 
      "date": "2019-09-27T08:08:45"                                                                                                                                                                         
    }                                                                                                                                                                                                       
  }                                                                                                                                                                                                         
}) for request https://graph.microsoft.com/v1.0/me                                                                                                                                                          
davido commented 5 years ago

I am afraid I am not able to assist you here.