apigee / apigee-deploy-maven-plugin

Apache License 2.0
80 stars 167 forks source link

access token not valid #171

Closed Feroz1991 closed 2 years ago

Feroz1991 commented 2 years ago

i am getting access token not valid error while i can use the same bearer token and deploy from my local. but from jenkins its rying through maven its not working

ssvaidyanathan commented 2 years ago

@Feroz1991 - pls make sure that the JWT you are passing matches the client_id and email you have in your pom

When you are passing a bearer token, make sure the Apigee Maven profile you are calling is also having and . The plugin verifies the JWT against those and checks it they match. If they don't then it throws the Invalid Access Token error

anoopsaxena commented 2 years ago

We are also getting the same error Access token not valid However we can upload ( Only upload, not deployed ) with the same bearer token in apigee env from local command prompt through maven command. From Jenkins pipeline its not working earlier. We changed the generated URL and now it's working fine. Correct URL: https://api.enterprise.apigee.com/v1/organizations/myOrg_name/apis?action=import&name=GIES_Boomi_PowerAutomate

Earlier it was: https://myOrg.apigee.com/v1/organizations/My_Org_name/apis?action=import&name=GIES_Boomi_PowerAutomate

Thanks

ssvaidyanathan commented 2 years ago

@anoopsaxena - not sure I am following what you mean.

Access token not valid could have three possible reasons 1) its not a valid token 2) the client id you are passing does not match with the value in the JWT 3) the username you are passing does not match with the value in the JWT

The URL configured incorrectly has nothing to do with the plugin issue.

ssvaidyanathan commented 2 years ago

@Feroz1991 - Can you please confirm if you still see the issue? If not, I would like to close the issue

shaunmirza commented 2 years ago

I am also experiencing the same issue. Apigee org is SSO enabled with external IDP. I am using the following command in my Jenkinsfile to deploy my proxy:

mvn -B install -P<<{ENVIRONMENT}>> -Dusername=<<{APIGEE_USERNAME}>> -Dorg=<<{ORG}>> -Dauthtype=oauth -Dbearer=<<{ACCESS_TOKEN}>> -DartifactName=<<{apiproxyName}>> -DapiType=apiproxy

The and are provided in the sharedpom.xml. The error returned in the logs goes as follows:

Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.2.2:deploy (deploy-bundle) on project SampleDeploy1: Access token not valid -> [Help 1]

ssvaidyanathan commented 2 years ago

@shaunmirza - Can you please decode your bearer token (using jwt.io) and see if the apigee.clientid matches from the value in the token and also the same for apigee.username. If they dont match, the plugin will raise "Access token not valid".

Also please check if the token is not expired.

ssvaidyanathan commented 2 years ago

@shaunmirza - any update on this? Else I will have to close this issue

shaunmirza commented 2 years ago

@shaunmirza - any update on this? Else I will have to close this issue

Clientid and username matched the token. The culprit was the tokenurl in the profile of the sharedpom.xml. I had to change it to my custom url. Everything works, thanks!