Richard Schaefer
Richard Schaefer

Reputation: 595

Github API Cannot Set User Emails

I'm trying to synchronize user names and primary emails with AD via the Github API. I make a call to /user/emails using an oAuth token with scope user:email and I get back their primary email. I then try to use PATCH /user per this doc with the payload:

{
   email: [email protected]
}

And I get back a 404.

Is this the correct method to set the primary emails for users?

Upvotes: 5

Views: 465

Answers (3)

Richard Schaefer
Richard Schaefer

Reputation: 595

Turns out the issue was a typo in the PATCH URL.

Upvotes: 1

I_Al-thamary
I_Al-thamary

Reputation: 4003

It requires authentication and it will return 404 Not Found, instead of 403 Forbidden, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.

You can try to make your email visibility to be public

[
  {
    "email": "[email protected]",
    "primary": true,
    "verified": true,
    "visibility": "public"
  }
]

Upvotes: 1

DinushaNT
DinushaNT

Reputation: 1147

This is due to your API request is not properly authenticated or your OAuth token does not have the required scopes. As per your question, you have set user:email scope which does not allow modification of the profile. Use user scope intead.

Scopes in Githup API

See more: Why am I getting a 404 error on a repository that exists?

Upvotes: 3

Related Questions