Help with OAuth Token Length Error in GitHub Source Action

0
0
Asked By CuriousCoder42 On

I'm facing an issue with my GitHub OAuth token when trying to use it in an AWS pipeline. I'm retrieving the token from Secrets Manager, but I'm getting this error saying: 'The OAuth token used for the GitHub source action Github_source exceeds the maximum allowed length of 100 characters.' Here's a snippet of my code where I'm adding the GitHub source action:

```javascript
pipeline.addStage({
stageName: "Source",
actions: [
new pipeActions.GitHubSourceAction({
actionName: "Github_source",
owner: "Me",
repo: "my-repo",
branch: "main",
oauthToken: cdk.SecretValue.secretsManager("my-github-token"),
output: outputSource,
}),
],
});
```

When I run the command to get the secret value, I see that the token I have is definitely less than 100 characters. However, when I log the secret after using `unsafeUnwrap()`, it returns something unexpected: `${Token[TOKEN.93]}`. If I log it without unwrapping, it shows a complex object instead. Can anyone help me figure out why I'm getting this error?

2 Answers

Answered By TokenTinkerer88 On

Definitely avoid using key/value pairs in the secret. Just delete the JSON and put the raw token in place. It will save you a lot of trouble!

CuriousCoder42 -

Is there a specific reason for this approach instead of the method I initially tried?

Answered By JavaScriptJunkie99 On

It looks like the issue arises because your secret is stored as a JSON object. You should just use the raw token instead of that JSON format. Simplify your secret value to the plain token string.

ThoughtfulDev23 -

I created the secret with the key set to "my-github-token" and the value as "string_thats_definitely_less_than_100_characters" without any JSON. I used unsafeUnwrap just to check what the secret is for debugging. Should I remove that part?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.