Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the use of authenticate() using ENV variable #1085

Closed
ucorpintegration opened this issue Sep 30, 2022 · 4 comments
Closed

Document the use of authenticate() using ENV variable #1085

ucorpintegration opened this issue Sep 30, 2022 · 4 comments

Comments

@ucorpintegration
Copy link

ucorpintegration commented Sep 30, 2022

In config/packages/github.yml , there is:

services:
    Github\Client:
        arguments:
            - '@Github\HttpClient\Builder'
        calls:
            - ['authenticate', ['%env(GITHUB_USERNAME)%', '%env(GITHUB_SECRET)%', '%env(GITHUB_AUTH_METHOD)%']]

But how to use it?
Not knowing how to use it, I temporarily put the credentials in the code.

@acrobat
Copy link
Collaborator

acrobat commented Sep 30, 2022

I'm not sure what you exact question is here. The service config above looks correct and you should define the mentioned environment variables then authentication is correctly setup.

After that you can inject the Github\Client service into you classes and call the api endpoints

@acrobat
Copy link
Collaborator

acrobat commented Oct 23, 2022

Closing this issue as I consider it answered/solved. Please re-open if you still have problem!

@acrobat acrobat closed this as completed Oct 23, 2022
@tresf
Copy link

tresf commented May 18, 2023

I have a similar issue as the OP. Configuring the environment is rather trivial, as @acrobat has identified, however troubleshooting issues is difficult because the parameters aren't part of any (obvious?) documentation.

For example, take the following .env file:

GITHUB_USERNAME=username
GITHUB_SECRET=password_or_token
GITHUB_AUTH_METHOD=http_password

If these are omitted, errors are as we'd expect...

- Environment variable not found: "GITHUB_USERNAME".
- Environment variable not found: "GITHUB_SECRET".
- Environment variable not found: "GITHUB_AUTH_METHOD".

And although GITHUB_USERNAME and GITHUB_SECRET are rather obvious, I feel that GITHUB_AUTH_METHOD is not. Searching this project for GITHUB_AUTH_METHOD returns one result (this bug report). Most examples recommend a value of http_password as mentioned, but this results in a new error:

- Github\Exception\RuntimeException: "http_token not yet implemented" at /home/owner/lmms.io/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/Authentication.php

Common sense says that this is incorrect usage (or perhaps an outdated library?) but my Google Fu is returning very little results, leaving doubt. 🍻

@tresf
Copy link

tresf commented May 18, 2023

I got it working using this, per

public const ACCESS_TOKEN = 'access_token_header';

- GITHUB_AUTH_METHOD=http_password
+ GITHUB_AUTH_METHOD=client_id_header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants