On the end user settings page, users can edit their email address and/or their secondary email address. When they do this, an email verification is sent to the new address before the change goes through. I could not find any Okta APIs that support this feature. Do they exist? Or how can we achieve this same thing?
I tried that using Postman with the interceptor turned on. It did not work, Iām getting 403 Forbidden. When I change the request mode to GET, it goes through fine. But when I change it to POST, it shows 403 Forbidden. The request body contains a JSON profile object with my updates.
Iām jumping in here because your original question was one I had on my to-do list to verify (pun intended).
First to address your last thing, ā/users/meā works if either the session cookie or the API access token is passed with the request (from the org authorization server, not a custom authorization server including default). So, if you capture cookies with the Postman interceptor and Postman sends the session cookie with the request it should work. I verified the API call over the weekend. I think maybe something is amiss in your interceptor configuration. Maybe youāre not hanging on to the session cookie?
Number two, just FYI developer accounts for me donāt seem to ever send an email to the secondEmail address now. This changed about a year ago. Production accounts still do. So if you are using a developer account for testing that could be an issue. @Andrea, any thoughts on that?
Number three: I want to refer Andrea back to the original question about generating a confirmation email. As I said earlier, this was on my list because when you change the email or secondEmail via āmeā using POST it just changes them blindly. If there is a way to force a confirmation email Iād love to know it because I too have not found that in the API. Maybe itās a developer vs production tenant thing?
Number four: FYI, if you change the email address it changes the login too. If you donāt want that, you have to specify both āemailā and āloginā in the data to the POST call to āmeā. But Iām guessing for your circumstances this is not an issue.
Thanks Joel, that is all helpful information. As for Postman - itās strange that the call works fine if I switch the request mode to GET. Itās only the POST version that fails. If I wanted to use a API access token then would I need to make my test user an admin, log in with their account, create one for them, and then use it in the users/me request? Otherwise how would Okta know who āmeā is in that context?
Without the API token (which, youāre right, can only be generated by Admins), the āmeā context is ascertained by the Okta session cookie (āsidā). If you log into Okta in the browser, youāll be able to access the /users/me endpoint in another tab based on the presence of this cookie.
@jmussman I actually hadnāt seen that behavior difference between a dev and a production org. So youāre saying the production org behaves as desired?
@cat Just FYI to get the Postman to work (your second response in this thread) the Origin header has to be set to the same as the original application request that set the āsidā (session) cookie. I donāt know of any documentation that states this. The GET request doesnāt require this so I suspected a header issue and and I isolated the Origin header in the POST request. I confirmed this is only an issue if the āsidā cookie is relied on to provide authorization for users/me in the API. If you use a bearer access token Origin doesnāt matter.
I still donāt have an answer for your last question to Andrea which is the important one, I hope she finds one
@cat FYI I did a whole bunch of testing to verify some stuff, the concise results are:
My developer accounts have a secondEmail, but it doesnāt appear in the user interface (look at settings) and it isnāt used. Just FYI in case youāre trying it there.
If you change either the primary email or secondEmail through the API, it assumes it is verified (look at the users/me with GET), putting the burden of verification on the application. Tested in both developer and production tenants.
If an admin changes a user email the same thing happens, it is assumed to be verified.
Confirmation that if you change the primary email the username changes. Support says that you could separate them in the request and make them different, but in default tenants the user cannot change the username property so it is rejected with a 403. You can change the rights for the user in the profile editor.
So the behavior is the same in a production tenant for updating secondEmail; it just puts it in as verified. @andrea, that leaves us back at the original question: can we change the secondEmail and have it marked as unverified and get a verification email sent? Probably a support ticket needs to be opened about this @cat.
Thank you Joel for those details! It is very helpful and will help many others as well Iām sure. Sounds good. I will open a support case. Iāll post back here with any progress.
I reached out to support, and they said that the feature does not exist. If you are interested in this feature, please upvote the Okta Ideas post I made for it: https://ideas.okta.com/app/#/case/144087